在IE6中設置display:block的空容器一個較小高度時,如<p style="height:1px;"></p>,會發現其高度不能小于某個值
<p style=”background: #f00; height: 1px; font-size:0″></p><!– demo1 –>
demo1:設置font-size:0,但是這個容器的高度最小為2px,所以沒有辦法實現高度為1px的效果
<p style=”background: #f00; height: 1px; line-height:0;”> </p> <!– demo2 –>
<p style=”background: #f00; height: 1px; line-height:0;”><br/></p> <!– demo3 –>
demo2 & demo3:在容器中增加內容或其他空標簽,如 、<br />,并設置line-height:0,雖然可實現效果,
但該容器會存在一個和其父容器字體大小有關的外邊距
<p style=”background: #f00; height: 1px; font-size:0;line-height:0″> </p><!– demo4 –>
<p style=”background: #f00; height: 1px; font-size:0;line-height:0″><br/></p><!– demo5 –>
demo4 & demo5:雖然可以解決外邊距的問題,但是在font-family:fixedsys(window的古老字體)等字體下還是會產生問題。
<p style=”background: #f00; height: 1px; overflow:hidden;”></p><!– demo6 –>
demo6:目前看到的最好的解決方案
新聞熱點
疑難解答