Css – Resize image to parent div

cssimagetwitter-bootstrap

I have an image with a 600px width.

It needs to be inside a bootstrap col-xs-6 or 12 div with a width of 300px and has to be resized if the screen width is smaller than 300px.

How can I realize that using width and max-width in CSS?

Best Answer

just do this:

img { 
  width: 100%; 
  max-width: 300px; 
  height: auto; 
}