火狐与IE兼容性总结(二)
16. 为什么web标准中IE无法设置滚动条颜色了
解决办法是将body换成html
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
- <styletype="text/css">
- <!--
- html {
- scrollbar-face-color:#f6f6f6;
- scrollbar-highlight-color:#fff;
- scrollbar-shadow-color:#eeeeee;
- scrollbar-3dlight-color:#eeeeee;
- scrollbar-arrow-color:#000;
- scrollbar-track-color:#fff;
- scrollbar-darkshadow-color:#fff;
- }
- -->
- </style>
17. 为什么我定义的样式没有作用呢
这里你无法用.aa定义到li 遇到这种情况怎么解决呢?答案是提高.aa 的优先权 比如#aa ul li.aa
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
- <styletype="text/css">
- <!--
- #aa ul li {
- color:red
- }
- .aa {
- color:blue
- }
- -->
- </style>
- <divid="aa">
- <ul>
- <liclass="aa">
- web标准常见问题大全
- </li>
- </ul>
- </div>
18. IE6无法定义1px左右高度的容器
IE6下这个问题是因为默认的行高造成的,解决的方法也有很多,例如:
- overflow:hidden zoom:0.08line-height:1px
19. 背景颜色无法显示
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
- <styletype="text/css">
- <!--
- ul {
- background:red
- }
- li {
- float:left;
- width:180px;
- }
- -->
- </style>
- <!--[if lte IE 6]>
- <style>
- .gainlayout { height: 1px; }
- </style>
- <![endif]-->
- <ulclass="gainlayout">
- <li>web标准常见问题大全</li>
- <li>web标准常见问题大全</li>
- <li>web标准常见问题大全</li>
- <li>web标准常见问题大全</li>
- <li>web标准常见问题大全</li>
- <divstyle="clear:both"></div>
- </ul>
IE中设置有背景色的ul并没有显示出来,这个属于haslayout问题,解决的办法也很多参考 http://www.satzansatz.de/cssd/onhavinglayout.htm
解决方法之一:
- <!--[if lte IE 6]>
- <style>
- .gainlayout { height: 1px; }
- </style>
- <![endif]-->
- <!--[if lte IE 6]>
- <style>
- .gainlayout { height: 1px; }
- </style>
- <![endif]-->
20. 怎么样才能让层显示在FLASH之上呢
解决的办法是给FLASH设置透明
- <paramname="wmode"value="transparent"/>
21. 怎样使一个层垂直居中于浏览器中
这里我们使用百分比绝对定位,与外补丁负值的方法,负值的大小为其自身宽度高度除以二
- <style type="text/css">
- <!--
- div {
- position:absolute;
- top:50%;
- left:50%;
- margin:-100px0 0-100px;
- width:200px;
- height:200px;
- border:1pxsolidred;
- }
- -->
- </style>
22. 图片垂直与容器内
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <styletype="text/css">
- <!--
- * {margin:0;padding:0}
- div {
- width:500px;
- height:500px;
- border:1px solid #ccc;
- overflow:hidden;
- position:relative;
- display:table-cell;
- text-align:center;
- vertical-align:middle
- }
- div p {
- position:static;
- +position:absolute;
- top:50%
- }
- img {
- position:static;
- +position:relative;
- top:-50%;left:-50%;
- width:276px;
- height:110px
- }
- -->
- </style>
- <div><p><imgsrc="logo.gif"/></p></div>
或者使用背景图的办法:
- background:url("logo.gif") centerno-repeat;
23. 如何让div横向排列
横向排列DIV可以使用浮动的方式比如float:left,或者设置对象为内联,还可以绝对定位对象等等.
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>
- <styletype="text/css">
- <!--
- div {
- float:left;
- width:200px;
- height:200px;
- border:1px solid red
- }
- -->
- </style>
- <div>web标准常见问题大全</div>
- <div>web标准常见问题大全</div>
- <div>web标准常见问题大全</div>
24 Firefox 关于DIV高度无法自适应的两种解决
如果设置了一个DIV的高度,当DIV里实际内容大于所设高度,ie会自动拉伸以适应DIV容器大小,ff会固定DIV的高度,超过部分超出DIV底线以外,
出现和下面的内容重叠的现象。如果不给DIV设置高度,在Firefox中将不回因为里面的内容而撑开,而IE中就会自动根据内容撑开
解决方案:
1、在DIV内部的最后追加clear:both样式
- <divstyle="background-color:#FF0000;">
- <divstyle="float:left; height:200px">Jmedia Design</div>
- <divstyle="float:right; height:800px">www.jmedia.cn</div>
- <divstyle="clear:both"></div>
- </div>
2、对DIV使用overflow:auto;
- <divstyle="overflow:auto;">
- <divstyle="float:left; background-color:#000000;height:200px">1111111111</div>
- <divstyle="float:right;background-color:#000000; height:300px"">2222222222</div>
- </div>
//成功一定有方法,失败一定有原因。
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步