ie6.0下div 实现1px高度

解决方法有如下几种:

1.加一个font-size=0px;的属性可以实现.

<style type="text/css">
.a
{
font-size
:0px;
height
:1px;
background-color
:red;
}

</style>
<div class="a"></div> 
但经过我的测试,细是细了,但不是1px,有点像是2px.不知道是我的浏览器问题,还是别的原因.你们可以用这个方法再测试一下.

 

2.多加一个line-height:1px的属性,不过得在div里多加一个&nbsp;,也就是空格.

 

<style type="text/css">
.a
{
width
:200px;
height
:1px;line-height:1px;
background
:red;
}

</style>
<div class="a">&nbsp;</div>

 

如果你要做指定长度的细线,这个方法是个不错的选择.
如果你的细线div长度是他父对象的长度的话,你可以用下面这个更简单的方法:

 

3.用border-top:1px solid #ff0000边框的方法制作一个细线.

<style type="text/css">
.a
{
border-top
:1px solid #ff0000;
}

</style>
<div class="a"></div> 

 

以上是网上的方法,自己用的方法是:

 

.line {
    background:#9ECEE2;
    line-height:1px;
    width:99%;
    margin:0 auto;
    *font-size:0px;
}
<div class=line>&nbsp;</div>

 

记住font-size 做(ie6) css hack 不然,IE8将不显示

posted @ 2009-04-08 10:24  朝夕  阅读(2209)  评论(1编辑  收藏  举报