<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
*{margin:0; padding:0;}
.A{background:#ccc; width:800px; height:50px; position:relative; top:0; left:0;}
.B{width:130px; height:6px; background:black; position:absolute; top:0; left:0;}
</style>
</head>
<body>
<div class="A">
<div class="B">
<img src="jiantou.png" width="130" height="6" alt="dw"/>
</div>
</div>
</body>
</html>
这是一张 高度6px, 宽度130px的PNG格式的图片
打开后在浏览器这么显示的
这是一个BUG吗?
改为:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
*{margin:0; padding:0;}
.A{background:#ccc; width:800px; height:50px;}
.B{width:130px; height:6px; background:black;}
</style>
</head>
<body>
<div class="A">
<div class="B">
<img src="jiantou.png" style="position:absolute" alt="dw"/>
</div>
</div>
</body>
</html>
http://blog.sina.com.cn/s/blog_6c21f6480101cb33.html
试试直接把img放到divb里面做背景 而不是插入
img设置为块级元素或者设置vertical-align:top
http://stackoverflow.com/questions/1518576/unwanted-padding-bottom-of-a-div