div+CSS 兼容小摘_html/css_WEB-ITnose

区别ie6与ff:
background:orange;*background:blue;
区别ie6与ie7:
background:green !important;background:blue;
区别ie7与ff:
background:orange; *background:green;
区别ff,ie7,ie6:
background:orange;*background:green !important;*background:blue;
ie7,ie8兼容:

head
1. css中几种浏览器对不同关键字的支持,可进行浏览器兼容性重复定义
!important 可被firefox和ie7识别
* 可被ie6、ie7识别
_ 可被ie6识别
*+ 可被ie7识别
2. ie专用的条件注释

3. 几个浏览器对实际像素的解释
ie/opera:对象的实际宽度 = (margin-left) + width + (margin-right)
firefox/mozilla:对象的实际宽度= (margin-left) + (border-left-width) + (padding- left) + width + (padding-right) + (border-right-width) + (margin-right)
4. 鼠标手势问题:firefox的cursor属性不支持hand,但是支持pointer,ie两个都支持;所以为了兼容都用pointer
5. firefox中设置html标签的style属性时,所有位置、宽高和尺寸值必须后跟px,ie也支持此写法,因此统一加px单位。如 obj.style.height = imgobj.style.height + ‘px’;
6. firefox无法解析简写的padding属性设置,如padding 5px 4px 3px 1px;必须改为 padding-top:5px; padding-right:4px; padding-bottom:3px; padding-left:1px0;
7. 消除ul、ol等列表的缩进时,样式应写成:list-style:none;margin:0px;padding:0px;其中margin属性对ie有效,padding属性对firefox有效
8. css控制透明:ie:filter:progid:dximagetransform.microsoft.alpha(style=0,opacity=60); firefox:opacity:0.6;
9. css控制圆角:ie:不支持圆角;
firefox: -moz-border-radius:4px;或
-moz-border-radius-topleft:4px;
-moz-border-radius-topright:4px;
-moz-border-radius-bottomleft:4px;
-moz-border-radius- bottomright:4px;
10. css双线凹凸边框:ie:border:2px outset;
firefox:
-moz-border-top-colors: #d4d0c8 white;
-moz-border-left-colors: #d4d0c8 white;
-moz-border-right-colors:#404040 #808080;
-moz-border-bottom-colors:#404040 #808080;
11. ie支持css方法cursor:url()自定义光标样式文件和滚动条颜色风格;firefox对以上两者均不支持
12. ie有select控件永远处于最上层的bug,且所有css对select控件都不起作用
13. ie支持form中的label标签,包括图片和文字内容;firefox不支持包含图片的label,点击图片不能让标记 label for 的radio或checkbox产生效果
14. firefox中的textarea不支持onscroll事件
15. firefox不支持display的inline和block
16. firefox对div设置margin-left, margin-right为auto时已经居中, ie中不行
17. firefox对body设置text-align时, div需要设置margin: auto(主要是margin-left margin-right) 方可居中
18. 对超链接的css样式设置最好遵从这样的顺序:l-v-h-a。即

<!–
a:link {}
a:visited {}
a:hover {}
a:active {}
–>

这样可以避免一些访问过后的超链接就不具备hover和active样式了
19. ie中设置长段落自动换行在css中设置word-wrap:break-word;firefox中使用js插入 的方法来实现,具体代码如下:

20. 在子容器加了浮动属性后,该容器将不能自动撑开
解决方法:在标签结束后下一个标签中加上一个清除浮动的css clear:both;
21. 浮动后ie6解释外边距为实际边距的双倍
解决办法:加上display:inline
22. ie6下图片下方会有空隙
解决办法:为img加上display:block或设置vertical-align 属性为vertical-align:top | bottom |middle |text-bottom
23. ie6下两个层中间有空隙
解决办法:设置右侧div也同样浮动float:left或者相对ie6定义 margin-right:-3px;
24. li中内容超过长度后以省略号的显示方法

<!–
li {
width:200px;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
overflow: hidden;
}
–>

25. 将元素的高度和行高设为相同值,即可垂直居中文本

<!–
div {
height:30px;
line-height:30px;
}
–>

26. 对齐文本与文本输入框,须在css中增加vertical-align:middle;属性设置

<!–
… …
vertical-align:middle;
}
–>

27. 支持web标准的浏览器设置了固定高度值就不会像ie6那样被撑开,但是又想设置固定高度又想能够被撑开呢?解决办法是去掉height属性而设置min-height,为了兼容不支持min-height的ie6可以这样定义:
{
height:auto!important;
height:200px;
min-height:200px;
}
28. web标准中ie无法设置滚动条颜色
解决办法:在css中对body的设置改为对html的

<!–
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;
}
–>

29. ie6由于默认行高问题无法定义1px左右高度的容器,
解决办法:在css中对容器设置如:overflow:hidden | zoom:0.08 | line-height:1px
30. 给flash设置透明属性可使层显示在flash之上

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/3088599.html

(0)
上一篇 2025年3月28日 09:24:04
下一篇 2025年3月28日 09:24:11

AD推荐 黄金广告位招租... 更多推荐

发表回复

登录后才能评论