Why is there a gap between my image and its containing box?

前端 未结 6 1748
夕颜
夕颜 2020-12-09 06:00

When my browser renders the following test case, there\'s a gap below the image. From my understanding of CSS, the bottom of the blue box should touch the bottom of the red

6条回答
  •  隐瞒了意图╮
    2020-12-09 06:32

    Because the image is inline it sits on the baseline. Try

    vertical-align: bottom;
    

    Alternately, in IE sometimes if you have whitespace around an image you get that. So if you remove all the whitespace between the div and img tags, that may resolve it.

提交回复
热议问题