1. CSS中几种浏览器对不同关键字的支持,可进行浏览器兼容性重复定义
*+ 可被IE7识别
2.IE专用的条件注释
<!--[if IE 7]>
<!-- 适合于IE7 -->
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
<!--[if lte IE 6]>
<!-- 适合于IE6及一下 -->
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->
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单位。
6.CSS控制透明:
IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60); FireFox:opacity:0.6;
7.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;
8.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;
9.IE支持CSS方法cursor:url()自定义光标样式文件和滚动条颜色风格;FireFox对以上两者均不支持
10.IE有Select控件永远处于最上层的bug,且所有CSS对Select控件都不起作用
11.IE支持Form中的Label标签,包括图片和文字内容;FireFox不支持包含图片的Label,点击图片不能让标记 label for 的Radio或CheckBox产生效果
12.FireFox中的TextArea不支持onScroll事件
13.FireFox不支持display的inline和block
14.IE中设置长段落自动换行在CSS中设置word-wrap:break-word;FireFox中使用JS插入 的方法来实现,具体代码如下:
<script type="text/javascript">
/* <![CDATA[ */
function toBreakWord(el, intLen){
var obj=document.getElementById(el);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+" ";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+=" "+strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById && !document.all) toBreakWord("div_id", 37);
/* ]]> */
</script>
15.在子容器加了浮动属性后,该容器将不能自动撑开
解决方法:在标签结束后下一个标签中加上一个清除浮动的CSS clear:both;
16.IE6下两个层中间有空隙
解决办法:设置右侧div也同样浮动float:left或者相对IE6定义 margin-right:-3px;
17.LI中内容超过长度后以省略号的显示方法
<style type="text/css">
<!--
li {
width:200px;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
overflow: hidden;
}
-->
</style>
18.对齐文本与文本输入框,须在CSS中增加vertical-align:middle;属性设置
<style type="text/css">
<!--
… …
vertical-align:middle;
}
-->
</style>
19.web标准中IE无法设置滚动条颜色
解决办法:在CSS中对body的设置改为对html的
<style type="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>
20.IE6由于默认行高问题无法定义1px左右高度的容器,
解决办法:在CSS中对容器设置如:overflow:hidden | zoom:0.08 | line-height:1px
21.给Flash设置透明属性可使层显示在Flash之上
<param name="wmode" value="transparent" /> <!-- 解决IE上的问题 //>
<embed wmode="transparent" …… > <!-- 解决FireFox上的问题 //>
22.FireFox设置Padding属性后会相应的增加Width和Height属性值,IE不会
解决办法:用!important方法多定义一套Height和Width
23.FireFox对div与div之间的空格是忽略的,但IE是处理的;因此尽量在两个相连的div之间不要有空格和回车,否则可能会造成不同浏览器之间格式不正确,比如著名的3px偏差;而且原因很难查明
形式如下格式
<div id="parent">
<div id="content"> </div>
</div>
当Content内容多时,即使parent设置了高度100%或auto,在不同浏览器下还是不能完好的自动伸展;解决办法在层的最下方产生一个高度为1的空格,代码如下
<div id="parent">
<div id="content"> </div>
<div style="font: 0px/0px sans-serif;clear: both;display: block"> </div>
</div>
24.IE和FireFox对字体small的尺寸解释不同,FireFox为13px,IE中为16px
25.IE和FireFox对空格的尺寸解释不同,FireFox为4px,IE中为8px
26.在netvibes的CSS看到一个片断
.transparent{
filter:alpha(opacity=12);
-moz-opacity:0.12;
opacity:0.12;
background-color:#000;
}
filter:alpha(opacity=12); 支持IE
-moz-opacity:0.12; 支持FF
opacity:0.12; css 3标准
原载: 大连网站建设 http://www.noonenet.cn/