我想要一个类似 HR 的背景图片。一个 2 像素宽的 gif 文件。
我研究了 HR 标签的样式,但浏览器问题太多..
使用了一个2px高的div,图像作为背景,但是在IE6中,有一个我似乎无法摆脱的填充。
欢迎提出任何建议!
CSS:
.hr {
margin: 0; padding: 0;
height: 2px;
background-image: url('images/help-hr.gif');
background-repeat: repeat-x;
background-color: green; /* just to see the padding in IE6 */
}
HTML:
<p>sky</p>
<div class="hr"></div>
<p>grass</p>
最佳答案
添加溢出:隐藏;
.hr {
margin: 0; padding: 0;
height: 2px;
background-image: url('images/help-hr.gif');
background-repeat: repeat-x;
background-color: green; /* just to see the padding in IE6 */
overflow:hidden;
}
关于带有背景图片的 CSS 假 HR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3850346/