The image corresponds to 100%, as usual, on any mobile platform that is not based on mobile devices, but not on a mobile device.
It does not work as expected, because you provide the parent .blog-img element .blog-img width of 100% .
You need to direct the nested img element of the descendant directly and set it to 100% width:
.blog-img img { height: auto; width: 100%; }
Depending on what you are trying to achieve, setting a min-width of 100% might be better in certain cases.
.blog-img img { height: auto; min-width: 100%; }
- Using
width: 100% stretches the img element to a width of 100% . - Using
max-width: 100% will increase the width of the img element to the maximum total width of the img resource. In other words, this will prevent the img element from stretching more than it actually is.
Here is a minimal example highlighting the difference:
<p>Using <code>max-width: 100%</code></p> <img style="max-width: 100%;" src="http://placehold.it/50" /> <p>Using <code>width: 100%</code></p> <img style="width: 100%;" src="http://placehold.it/50" />
Since you are optimizing your site for mobile browsers, be sure to set the watch tag metafile :
<meta name="viewport" content="width=device-width, initial-scale=1">
source share