html

Changing Size of Image in CSS  #angularjs #reactjs

  • Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears…
  • Stack Overflow works best with JavaScript enabled
  • You can use object-fit: cover and object-fit: contain to achieve this.
  • I’d like to control the size of this image so that it fits a certain size, like 300px x 200px.

I’d like to control the size of this image so that it fits a certain size, like 300px x 200px. I want to keep the proportions, fill my area, but cut off any excess, as it would if I were to do a background “cover”

@ng_real_ninja: Changing Size of Image in CSS #angularjs #reactjs

I have HTML and don’t have much control over it, but I have full control over the CSS. One tag is an image tag:

I’d like to control the size of this image so that it fits a certain size, like 300px x 200px. I want to keep the proportions, fill my area, but cut off any excess, as it would if I were to do a background “cover”

Like this:

Is there any CSS trick to do this? Or any other trick?

Next time can you not post a link but you do it – UnknownDeveloper 2 hours ago

Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears… 🙁 Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! 😉 You can always leave the link in at the bottom of your answer as a source for your material… – Donald Duck 2 hours ago

html