我有一个 100% 宽度的 DIV.....在网格系统中..总网格是 1140px..
无论如何在 100% 的 div 中我插入了一张图片...
问题是如果 div 背景是黑色的......底部有 1cm 的地方仍然显示黑色。
像这样
<div style="background:black; width:100%;">
<img src="http://i42.tinypic.com/ofq9tg.png" >
我应该在图像上使用 float 吗?还是使用 display:block?
最佳答案
给你 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/