2

I'm trying to have a stack of divs with fullscreen image as its child, but the parent div height doesn't match the img height.

The CSS is not too complicated

  .content {
    overflow: hidden;
    position: relative;

    min-width: 1024px

  }

  .content img {
    width: 100%;
    height: auto;
  }

Here's the JSBin http://jsbin.com/baqexonu/1/ , you'll notice a 2px gap between the divs

please help.

badcoder
  • 191
  • 3
  • 13
  • 2
    It's the white-space. Add `line-height: 0` to `.content`. – Jack Mar 04 '14 at 07:44
  • @badcoder It's better to use `vertical-align: bottom;` for the images as: `.content img { vertical-align: bottom; }`. [reference](http://stackoverflow.com/questions/18428997/center-image-element-in-parent-div/18429014#18429014). – Hashem Qolami Mar 04 '14 at 09:50

2 Answers2

4

It's the white-space. Add line-height: 0 to .content.

Jack
  • 9,151
  • 2
  • 32
  • 44
2

You can also add display: block to .content img.

Mathias
  • 5,642
  • 2
  • 31
  • 46
  • Thank you. This explains where the space is coming from, ie inline(-block) elements flowing and leaving space between lines. Adding line-height: 0 was voodoo for me personally. – user2357 Feb 23 '19 at 16:45