这篇文章主要介绍了关于HTML条件注释用法诠释 ,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
HTML条件注释用法诠释
注释内容以样式为例,如下:
1、支持所有IE浏览器
1 2 3 | <!--[ if IE]>
<link rel= "stylesheet" href= "all-ie-only.css" type= "text/css" />
<![ endif ]-->
|
Salin selepas log masuk
2、支持非IE浏览器
1 2 3 | <!--[ if !IE]>
<link rel= "stylesheet" href= "not-ie.css" type= "text/css" />
<![ endif ]-->
|
Salin selepas log masuk
上面是除了IE浏览器外所有浏览器都识别这个样式,另外CSS-TRICKS的《How To Create an IE-Only Stylesheet》一文中提供了另一种写法:
1 | <!--[ if !IE]><!--><link rel= "stylesheet" type= "text/css" href= "not-ie.css" /><!--<![ endif ]-->
|
Salin selepas log masuk
3、仅仅支持IE10
1 2 3 | <!--[ if IE 10]>
<link rel= "stylesheet" type= "text/css" href= "ie10.css" >
<![ endif ]-->
|
Salin selepas log masuk
4、支持IE10以下版本(IE9以及IE9以下版本)
这种方法是样式表使用在低于IE10的浏览器,换句话说除了IE10以外的所有IE版本都将被支持。
1 2 3 | <!--[ if lt IE 10]>
<link rel= "stylesheet" type= "text/css" href= "ie9-and-down.css" >
<![ endif ]-->
|
Salin selepas log masuk
也可以写成
1 2 3 | <!--[ if lte IE 9]>
<link rel= "stylesheet" type= "text/css" href= "ie9-and-down.css" >
<![ endif ]-->
|
Salin selepas log masuk
前面我们也说过了lt和lte的区别,lt表示小于版本号,不包括条件版本号本身;而lte是小于或等于版本号,包括了版本号自身
。
上面这几种方法,使用的是低于(lt)和低于或等于(lte)的方法来判断,我们也可以使用大于gt
和大于或等于gte
达到上面的效果:
5、高于IE9的版本(IE10以及IE10以上版本)
1 2 3 | <!--[ if gt IE 9]>
<link rel= "stylesheet" type= "text/css" href= "ie10-and-up.css" >
<![ endif ]-->
|
Salin selepas log masuk
或
1 2 3 | <!--[ if gte IE 10]>
<link rel= "stylesheet" type= "text/css" href= "ie10-and-up.css" >
<![ endif ]-->
|
Salin selepas log masuk
6、指定多种IE版本
1 2 3 | <!--[ if (IE 6)|(IE 7)|(IE 8)]>
<link rel= "stylesheet" type= "text/css" href= "ie6-7-8.css" >
<![ endif ]-->
|
Salin selepas log masuk
参考:
https://www.cnblogs.com/hushufang/p/3708704.html
相关推荐:
HTML5中audio与video标签的使用
Atas ialah kandungan terperinci HTML条件注释用法诠释. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!