浏览器兼容
来源:互联网 发布:淘宝部分退款在哪 编辑:程序博客网 时间:2024/05/20 07:53
第二步,用IF语句来判断浏览器。
<!--[if IE]>
这段文字只在IE浏览器上显示
<![endif]-->
<!--[if IE 6]>
这段文字只在IE6浏览器上显示
<![endif]-->
<!--[if gt IE 6]>
这段文字只在IE6以上版本IE浏览器上显示
<![endif]-->
<!--[if ! IE 7]>
这段文字在非IE7浏览器上显示
<![endif]-->
<!--[if !IE]><!-->
这段文字只在非IE浏览器上显示
<!--<![endif]-->
词语解释:
lte:就是Less than or equal to的简写,也就是小于或等于的意思。
lt :就是Less than的简写,也就是小于的意思。
gte:就是Greater than or equal to的简写,也就是大于或等于的意思。
gt :就是Greater than的简写,也就是大于的意思。
! :就是不等于的意思,跟javascript里的不等于判断符相同
三、IE浏览器几种版本的样式区别
因为CSS3在IE9下是可以正常渲染,但是在IE8及以下版本不支持,此时我们又想让IE8及以下浏览器能够实现同样的效果。
“\9″ 只在IE6/IE7/IE8/IE9/IE10下生效
“\0” 只在 IE8/IE9/IE10下生效
“\9\0” 只在IE9/IE10下生效
如果只需要针对IE8的CSS,可先使用在IE8/IE9/IE10生效的“\0,再用仅在IE9/IE10生效的“\9\0”覆盖之前的样式。
例如:
selector{
color:#000;color:#F00\0; /* only for IE8&IE9&IE10 */
color:#000\9\0; /* only for IE9&IE10 */
}
这样就能在IE8中的颜色显示为:#F00
下面是IE5~IE9,Opera 9.5-9.6/FF 3.51-FF4,Safari,Google Chrome,Opera9.2,FF2/FF3.0/K-Meleon的样式
#example{
background:#036; /*Moz (& All browsers FF2/FF3.0/K-Meleon) 蓝色(#036)*/
_background:#F00; /*IE5 (& IE5.5/IE6) 红色(#F00)*/
/background:#630; /*IE8 beta1 褐色(#630)*/
background:#09F\0; /*IE8/IE9 */
background:#09F\0/; /*IE8 only 蓝色(#09F)*/
}
:root #example { background:#963\0 } /*IE9 only 咖啡色(#963)*/
#example{
*background:#f60; /*IE7 (& IE5.5/IE6) 橘色(#f60)*/
_background:#000; /*IE6 (& IE5.5) 黑色(#000)*/
_background:#390; /*IE5.5 绿色(#390)*/
}
@media all and (min-width:0){ /*webkit and opera */
#example{background:#f06;} /*Opera 9.5-9.6/FF 3.51-FF4, 粉色(#f06)*/
}
@media screen and (-webkit-min-device-pixel-ratio:0){
#example{background:#609;} /*webkit (& Safari,Google Chrome,Opera9.2, 紫色(#609)*/
}
/* webkit */
@media screen and (-webkit-min-device-pixel-ratio:0){ #example{} }
/* opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { #example{} }
/* firefox */
@-moz-document url-prefix(){ #example{} }
复制代码
代码如下:<!--[if IE]>
这段文字只在IE浏览器上显示
<![endif]-->
<!--[if IE 6]>
这段文字只在IE6浏览器上显示
<![endif]-->
<!--[if gt IE 6]>
这段文字只在IE6以上版本IE浏览器上显示
<![endif]-->
<!--[if ! IE 7]>
这段文字在非IE7浏览器上显示
<![endif]-->
<!--[if !IE]><!-->
这段文字只在非IE浏览器上显示
<!--<![endif]-->
词语解释:
lte:就是Less than or equal to的简写,也就是小于或等于的意思。
lt :就是Less than的简写,也就是小于的意思。
gte:就是Greater than or equal to的简写,也就是大于或等于的意思。
gt :就是Greater than的简写,也就是大于的意思。
! :就是不等于的意思,跟javascript里的不等于判断符相同
三、IE浏览器几种版本的样式区别
因为CSS3在IE9下是可以正常渲染,但是在IE8及以下版本不支持,此时我们又想让IE8及以下浏览器能够实现同样的效果。
复制代码
代码如下:“\9″ 只在IE6/IE7/IE8/IE9/IE10下生效
“\0” 只在 IE8/IE9/IE10下生效
“\9\0” 只在IE9/IE10下生效
如果只需要针对IE8的CSS,可先使用在IE8/IE9/IE10生效的“\0,再用仅在IE9/IE10生效的“\9\0”覆盖之前的样式。
例如:
复制代码
代码如下:selector{
color:#000;color:#F00\0; /* only for IE8&IE9&IE10 */
color:#000\9\0; /* only for IE9&IE10 */
}
这样就能在IE8中的颜色显示为:#F00
下面是IE5~IE9,Opera 9.5-9.6/FF 3.51-FF4,Safari,Google Chrome,Opera9.2,FF2/FF3.0/K-Meleon的样式
复制代码
代码如下:#example{
background:#036; /*Moz (& All browsers FF2/FF3.0/K-Meleon) 蓝色(#036)*/
_background:#F00; /*IE5 (& IE5.5/IE6) 红色(#F00)*/
/background:#630; /*IE8 beta1 褐色(#630)*/
background:#09F\0; /*IE8/IE9 */
background:#09F\0/; /*IE8 only 蓝色(#09F)*/
}
:root #example { background:#963\0 } /*IE9 only 咖啡色(#963)*/
#example{
*background:#f60; /*IE7 (& IE5.5/IE6) 橘色(#f60)*/
_background:#000; /*IE6 (& IE5.5) 黑色(#000)*/
_background:#390; /*IE5.5 绿色(#390)*/
}
@media all and (min-width:0){ /*webkit and opera */
#example{background:#f06;} /*Opera 9.5-9.6/FF 3.51-FF4, 粉色(#f06)*/
}
@media screen and (-webkit-min-device-pixel-ratio:0){
#example{background:#609;} /*webkit (& Safari,Google Chrome,Opera9.2, 紫色(#609)*/
}
/* webkit */
@media screen and (-webkit-min-device-pixel-ratio:0){ #example{} }
/* opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { #example{} }
/* firefox */
@-moz-document url-prefix(){ #example{} }
0 0
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- 浏览器兼容
- maven学习(1)
- 底部带图标的导航选项卡的两种实现方式
- 插入排序和希尔排序
- mysql in 子查询 效率慢 优化(转)
- Intent 详解
- 浏览器兼容
- 计算合式公式(wff) 【让你的离散作业变的更轻松】
- nginx、TP框架实现兼容pathinfo和rewrite两种url访问方式
- Android图片轮播控件 如果对你有帮助请star哦!
- Android之蓝牙 详细使用操作步骤
- iOS 应用内跳转到百度地图、苹果地图、谷歌地图、高德地图等
- android性能优化-----TraceView
- sql之left join、right join、inner join的区别
- 字符拆分 邮箱