If I have an image on a page with width set to 100% in css it is as wide as the browser. Fine. However, if I make a containing div have display:inline-block, then the image is n
This is because a percentage value on width is relative to the width of the box's containing block. While a block-level container ( Therefore you have to specify the width of the wrapper Alternatively, in cases where you want to set the width of elements as the width of the viewport/window, you could use viewport percentage units instead. For instance: Demo:100% you should ask yourself 100% of what?
img { width:100%; }
div { display:inline-block; width: 100%; }
img { width: 100vw; } /* 1vw = 1/100 of the width of the viewport */
img { width: 100vw; }