火狐与IE兼容性总结(二)

16.    为什么web标准中IE无法设置滚动条颜色了
    解决办法是将body换成html

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
  3. <styletype="text/css">
  4. <!--
  5. html {
  6.          scrollbar-face-color:#f6f6f6;
  7.          scrollbar-highlight-color:#fff;
  8.          scrollbar-shadow-color:#eeeeee;
  9.          scrollbar-3dlight-color:#eeeeee;
  10.          scrollbar-arrow-color:#000;
  11.          scrollbar-track-color:#fff;
  12.          scrollbar-darkshadow-color:#fff;
  13.      }
  14. -->
  15. </style>

17.    为什么我定义的样式没有作用呢 
    这里你无法用.aa定义到li 遇到这种情况怎么解决呢?答案是提高.aa 的优先权 比如#aa ul li.aa

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
  3. <styletype="text/css">
  4.      <!--
  5.      #aa ul li {
  6.              color:red
  7.          }
  8.      .aa {
  9.              color:blue
  10.          }
  11.      -->
  12. </style>    
  13. <divid="aa">    
  14. <ul>
  15. <liclass="aa">    
  16.      web标准常见问题大全
  17. </li>
  18. </ul>
  19. </div>

18.    IE6无法定义1px左右高度的容器 
    IE6下这个问题是因为默认的行高造成的,解决的方法也有很多,例如:

  1. overflow:hidden zoom:0.08line-height:1px

19.    背景颜色无法显示

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
  3. <styletype="text/css">
  4. <!--
  5. ul {
  6.          background:red
  7.      }
  8. li {
  9.          float:left;
  10.          180px;
  11.      }
  12. -->
  13. </style>
  14. <!--[if lte IE 6]>
  15. <style>
  16. .gainlayout { height: 1px; }
  17. </style>
  18. <![endif]-->  
  19. <ulclass="gainlayout">
  20. <li>web标准常见问题大全</li>
  21. <li>web标准常见问题大全</li>
  22. <li>web标准常见问题大全</li>
  23. <li>web标准常见问题大全</li>
  24. <li>web标准常见问题大全</li>
  25. <divstyle="clear:both"></div>
  26. </ul>

IE中设置有背景色的ul并没有显示出来,这个属于haslayout问题,解决的办法也很多参考 http://www.satzansatz.de/cssd/onhavinglayout.htm 
    解决方法之一:

  1. <!--[if lte IE 6]>
  2. <style>    
  3. .gainlayout { height: 1px; }    
  4. </style>    
  5. <![endif]-->     
  6. <!--[if lte IE 6]>
  7. <style>
  8. .gainlayout { height: 1px; }
  9. </style>
  10. <![endif]-->

20.    怎么样才能让层显示在FLASH之上呢
    解决的办法是给FLASH设置透明

  1. <paramname="wmode"value="transparent"/>  

21.    怎样使一个层垂直居中于浏览器中
    这里我们使用百分比绝对定位,与外补丁负值的方法,负值的大小为其自身宽度高度除以二

  1. <style type="text/css">    
  2. <!--     
  3. div {    
  4.         position:absolute;    
  5.          top:50%;    
  6.          left:50%;    
  7.         margin:-100px0 0-100px;    
  8.         width:200px;    
  9.         height:200px;    
  10.         border:1pxsolidred;    
  11.      }    
  12. -->    
  13. </style>

22.    图片垂直与容器内

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <styletype="text/css">
  3. <!--
  4. * {margin:0;padding:0}
  5. div {
  6.          500px;
  7.          height:500px;
  8.          border:1px solid #ccc;
  9.          overflow:hidden;
  10.          position:relative;
  11.          display:table-cell;
  12.          text-align:center;
  13.          vertical-align:middle
  14.      }
  15. div p {
  16.          position:static;
  17.          +position:absolute;
  18.          top:50%
  19.      }
  20. img {
  21.          position:static;
  22.          +position:relative;
  23.          top:-50%;left:-50%;
  24.          276px;
  25.          height:110px
  26.      }
  27. -->
  28. </style>
  29. <div><p><imgsrc="logo.gif"/></p></div>

或者使用背景图的办法:

  1. background:url("logo.gif") centerno-repeat;

23.    如何让div横向排列
    横向排列DIV可以使用浮动的方式比如float:left,或者设置对象为内联,还可以绝对定位对象等等.

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">    
  2. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>    
  3. <styletype="text/css">    
  4. <!--     
  5. div {    
  6.          float:left;
  7.          200px;
  8.          height:200px;
  9.          border:1px solid red
  10.      }
  11. -->
  12. </style>
  13. <div>web标准常见问题大全</div>
  14. <div>web标准常见问题大全</div>
  15. <div>web标准常见问题大全</div>

24 Firefox 关于DIV高度无法自适应的两种解决
    如果设置了一个DIV的高度,当DIV里实际内容大于所设高度,ie会自动拉伸以适应DIV容器大小,ff会固定DIV的高度,超过部分超出DIV底线以外,
    出现和下面的内容重叠的现象。如果不给DIV设置高度,在Firefox中将不回因为里面的内容而撑开,而IE中就会自动根据内容撑开
    解决方案:
    1、在DIV内部的最后追加clear:both样式

  1. <divstyle="background-color:#FF0000;">
  2.     <divstyle="float:left; height:200px">Jmedia Design</div>
  3.     <divstyle="float:right; height:800px">www.jmedia.cn</div>
  4.     <divstyle="clear:both"></div>
  5. </div>

    2、对DIV使用overflow:auto;

  1. <divstyle="overflow:auto;">
  2.     <divstyle="float:left; background-color:#000000;height:200px">1111111111</div>
  3.     <divstyle="float:right;background-color:#000000; height:300px"">2222222222</div>
  4. </div>

//成功一定有方法,失败一定有原因。
原文地址:https://www.cnblogs.com/webapi/p/2425970.html