Regarding the problem of how many pixels more will the height of the img parent container be than the height of img? -PHP Chinese website Q&A-How many pixels more will the height of the img parent container be than the height of the img? -PHP Chinese website Q&A
Regarding the problem of how many pixels more will the height of the img parent container be than the height of img? -PHP Chinese website Q&A-How many pixels more will the height of the img parent container be than the height of the img? -PHP Chinese website Q&A
Let’s take a look and learn.
这是因为浏览器本身对img标签的渲染问题,img标签本身是行内元素(主要原因)所以有一种简单有效的解决办法(推荐)
img { display:block;}或者可以尝试为父级div设置font-size:0(不推荐)
也可以采用浮动(float),原因是浮动会将这个元素转换为块级元素
当然还有为div定高并且设置overflow:hidden的解决办法(太不优雅了,强烈不推荐)