zoukankan      html  css  js  c++  java
  • 【IE大叔开玩笑】之——CSS设置IE6中容器高度的BUG

    在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;">&nbsp;</p> <!-- demo2 -->
    <p style="background: #f00; height: 1px; line-height:0;"><br/></p> <!-- demo3 -->

    demo2demo3:在容器中增加内容或其他空标签,如&nbsp;、<br />,并设置line-height:0,虽然可实现效果,

              但该容器会存在一个和其父容器字体大小有关的外边距

    <p style="background: #f00; height: 1px; font-size:0;line-height:0">&nbsp;</p><!-- demo4 -->
    <p style="background: #f00; height: 1px; font-size:0;line-height:0"><br/></p><!-- demo5 -->

     demo4demo5:虽然可以解决外边距的问题,但是在font-family:fixedsys(window的古老字体)等字体下还是会产生问题。

    <p style="background: #f00; height: 1px; overflow:hidden;"></p><!-- demo6 -->

    demo6:目前看到的最好的解决方案

     推荐详细了解IE大叔的各种奇葩毛病

  • 相关阅读:
    Ajax在表单中的应用
    jQuery实例
    Ajax之404,200等查询
    Ajax知识总结
    Ajax之eval()函数
    闭包应用
    全局预处理与执行,作用域与作用域链
    替换富文本里的px为rem
    vue2 兼容ie8
    vue-awesome-swiper 水平滚动异常
  • 原文地址:https://www.cnblogs.com/ccto/p/2944360.html
Copyright © 2011-2022 走看看