html - css 图像不填充 div

标签 html css image

我有一个 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" >

我应该在图像上使用 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/

相关文章:

jquery - 使用没有 id 的 jQuery 排序元素

css - 在一个 div : one of fixed width and the other of variable width/height 中居中两个 div

css - 气泡图的背景图片

ios - 如何设置背景图片,但不在 Swift iOS 中的状态栏后面

html - 哪种CSS组织方式最快?

ruby-on-rails - Rails,在 form_for 标签自定义文本中插入 span 标签

java - 如何将JFreeChart的图形保存为PNG图像?

python - 如何在 Django 中访问通过表单集上传的图像?

html - xslt disable-output-escaping 将非拉丁字符变成问号 "...???????????..."

javascript - JS : How to hide parent div with multiple nested divs, 基于子 div 的内容