CSS兼容性问题汇总
2016-04-11 16:36
453 查看
1.css透明度问题:
对于高版本对CSS3支持度较高的浏览器可以使用opacity,对于IE,可以使用filter。
IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60)。
FF:opacity:0.6。
2.display:table,table-row,table-cell:
这些属性在IE6,IE7中不兼容,可以使用css hack技术;
3.ie6双倍边距:
设置为float的div在ie下设置的margin会加倍
display:inline;
4.ie6不支持最小高度和最小宽度:
使用csshack
/* 最小宽度 */
.min_width{
min-width:300px;
_width:expression(parseInt(this.clientWidth) < 300 ? "300px" : this.clientWidth);
}
/* 最大宽度 */
.max_width{
max-width:600px;
_width:expression(parseInt(this.clientWidth) > 600 ? "600px" : this.clientWidth);
}
5.css3圆角问题
IE:ie7以下不支持圆角,
其他浏览器:-moz-border-radius,-webkit-border-radius,border-radius
6.ie6.0下默认有行高
解决方法:overflow:hidden;
7.Ie6里面:如li设宽、高,并且li里面的标签浮动,那么li之间会有间距
解决方法:li不设宽、高或者li内的标签不浮动。
8.ie6 不支持 fixed
/*对于非IE6可以这样写*/
#top{
position:fixed;
bottom:0;
right:20px;
}
/*但是IE6是不支持fixed定位的,需要另外重写*/
#top{
position:fixed;
_position:absolute;
top:0;
right:20px;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop));
}
/*使用hack使IE6实现该效果,但这个东东会闪烁,需要以下代码*/
*html{
background-image:url(about:blank);
background-attachment:fixed;
}
/*使固定在顶部*/
#top{
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop));
}
/*固定在底部*/
#top{
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop)||0)- (parseInt(this.currentStyle.marginBottom)||0)));
}
/*垂直居中*/
#top{
position:fixed;
top:50%;
margin-top:-50px;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight/2));
}
9.z-index不起作用的BUG
1)ie6下 首先讲讲第一种z-index无论设置多高都不起作用情况。这种情况发生的条件有三个:1、父标签position属性为relative;2、问题标签含有浮动(float)属性。
2)所有浏览器:它只认父元素
层级的高低不仅要看自己,还要看自己的老爸这个后台是否够硬。用术语具体描述为:
父标签position属性为relative或absolute时,子标签的absolute属性是相对于父标签而言的。而在IE6下,层级的表现有时候不是看子标签的z-index多高,而要看它们的父标签的z-index谁高谁低。
对于高版本对CSS3支持度较高的浏览器可以使用opacity,对于IE,可以使用filter。
IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60)。
FF:opacity:0.6。
2.display:table,table-row,table-cell:
这些属性在IE6,IE7中不兼容,可以使用css hack技术;
3.ie6双倍边距:
设置为float的div在ie下设置的margin会加倍
display:inline;
4.ie6不支持最小高度和最小宽度:
使用csshack
/* 最小宽度 */
.min_width{
min-width:300px;
_width:expression(parseInt(this.clientWidth) < 300 ? "300px" : this.clientWidth);
}
/* 最大宽度 */
.max_width{
max-width:600px;
_width:expression(parseInt(this.clientWidth) > 600 ? "600px" : this.clientWidth);
}
5.css3圆角问题
IE:ie7以下不支持圆角,
其他浏览器:-moz-border-radius,-webkit-border-radius,border-radius
6.ie6.0下默认有行高
解决方法:overflow:hidden;
7.Ie6里面:如li设宽、高,并且li里面的标签浮动,那么li之间会有间距
解决方法:li不设宽、高或者li内的标签不浮动。
8.ie6 不支持 fixed
/*对于非IE6可以这样写*/
#top{
position:fixed;
bottom:0;
right:20px;
}
/*但是IE6是不支持fixed定位的,需要另外重写*/
#top{
position:fixed;
_position:absolute;
top:0;
right:20px;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop));
}
/*使用hack使IE6实现该效果,但这个东东会闪烁,需要以下代码*/
*html{
background-image:url(about:blank);
background-attachment:fixed;
}
/*使固定在顶部*/
#top{
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop));
}
/*固定在底部*/
#top{
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop)||0)- (parseInt(this.currentStyle.marginBottom)||0)));
}
/*垂直居中*/
#top{
position:fixed;
top:50%;
margin-top:-50px;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight/2));
}
9.z-index不起作用的BUG
1)ie6下 首先讲讲第一种z-index无论设置多高都不起作用情况。这种情况发生的条件有三个:1、父标签position属性为relative;2、问题标签含有浮动(float)属性。
2)所有浏览器:它只认父元素
层级的高低不仅要看自己,还要看自己的老爸这个后台是否够硬。用术语具体描述为:
父标签position属性为relative或absolute时,子标签的absolute属性是相对于父标签而言的。而在IE6下,层级的表现有时候不是看子标签的z-index多高,而要看它们的父标签的z-index谁高谁低。
相关文章推荐
- CSS的水平居中与垂直居中
- CSS强制英文、中文换行与不换行 强制英文换行
- [1] Word样式/主题/模板
- CSS3学习系列之颜色
- css display:box 新属性
- css3-新增的选择器
- CSS3之边框图片
- POI Excel导出样式设置
- <css 十一>relative相对定位、absolute绝对定对
- CSS效果
- 导入样式表与链入样式表区别
- HTML/CSS测试代码二
- PowerDesigner的样式设置
- sass 学习总结1
- @import导入外部样式表与link链入外部样式表的区别
- CSS样式表与格式布局
- 搞清楚CSS单位px、em、rem、vh、vw、vmin、vmax
- 使用CSS3编写类似iOS中的复选框及带开关的按钮
- Css3 - 动画旋转
- CSS3之圆角