我有一个 100% 宽度的 DIV..... 在网格系统内.. 总网格是 1140px..

无论如何,在 100% 的 div 中,我插入了一个图像...

问题是如果 div 背景是黑色的......底部有 1cm 仍然显示黑色。

像这样

http://jsfiddle.net/hb3QK/3/

<div style="background:black; width:100%;">
  <img src="http://i42.tinypic.com/ofq9tg.png" >

我应该在图像上使用浮点数吗?或使用显示:块?

最佳答案

在这里你做
http://jsfiddle.net/cancerian73/hb3QK/4/

img {
    height: auto; /* Make sure images are scaled correctly. */
width: 100%; /* Adhere to container width. */
display:block;
 }

关于html - css 图像没有填充 div,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20449209/

10-12 12:50
查看更多