HTML条件注释用法诠释


HTML条件注释用法诠释

注释内容以样式为例,如下:

1、支持所有IE浏览器

<!--[if IE]>

<link rel="stylesheet" href="all-ie-only.css" type="text/css"/>

<![endif]-->

2、支持非IE浏览器

<!--[if !IE]>

<link rel="stylesheet" href="not-ie.css" type="text/css"/>

<![endif]-->

上面是除了IE浏览器外所有浏览器都识别这个样式,另外CSS-TRICKS的《How To Create an IE-Only Stylesheet》一文中提供了另一种写法:

<!--[if !IE]><!-->

<link rel="stylesheet" type="text/css" href="not-ie.css" />

<!--<![endif]-->

3、仅仅支持IE10

<!--[if IE 10]>

<link rel="stylesheet" type="text/css" href="ie10.css">

<![endif]-->

4、仅仅支持IE9

<!--[if IE 9]>

<link rel="stylesheet" type="text/css" href="ie9.css">

<![endif]-->

5、仅仅支持IE8

<!--[if IE 8]>

<link rel="stylesheet" type="text/css" href="ie8.css">

<![endif]-->

6、仅仅支持IE7

<!--[if IE 7]>

<link rel="stylesheet" type="text/css" href="ie7.css">

<![endif]-->

7、仅仅支持IE6

<!--[if IE 6]>

<link rel="stylesheet" type="text/css" href="ie6.css">

<![endif]-->

8、支持IE10以下版本(IE9以及IE9以下版本)

这种方法是样式表使用在低于IE10的浏览器,换句话说除了IE10以外的所有IE版本都将被支持。

<!--[if lt IE 10]>

<link rel="stylesheet" type="text/css" href="ie9-and-down.css">

<![endif]-->

也可以写成

<!--[if lte IE 9]>

<link rel="stylesheet" type="text/css" href="ie9-and-down.css">

<![endif]-->

前面我们也说过了lt和lte的区别,lt表示小于版本号,不包括条件版本号本身;而lte是小于或等于版本号,包括了版本号自身。

9、支持IE9以下版本(IE8以及IE8以下版本)

<!--[if lt IE 9]>

<link rel="stylesheet" type="text/css" href="ie8-and-down.css">

<![endif]-->

或:

<!--[if lte IE 8]>

<link rel="stylesheet" type="text/css" href="ie8-and-down.css">

<![endif]-->

10、支持IE8以下版本(IE7以及IE7以下版本)

<!--[if lt IE 8]>

<link rel="stylesheet" type="text/css" href="ie7-and-down.css">

<![endif]-->

或:

<!--[if lte IE 7]>

<link rel="stylesheet" type="text/css" href="ie7-and-down.css">

<![endif]-->

11、支持IE7以下版本(IE6以及IE6以下版本)

<!--[if lt IE 7]>

<link rel="stylesheet" type="text/css" href="ie6-and-down.css">

<![endif]-->

或:

<!--[if lte IE 6]>

<link rel="stylesheet" type="text/css" href="ie6-and-down.css">

<![endif]-->

上面8——11这几种方法,使用的是低于(lt)和低于或等于(lte)的方法来判断,我们也可以使用大于(gt)和大于或等于(gte)达到上面的效果:

12、高于IE9的版本(IE10以及IE10以上版本)

<!--[if gt IE 9]>

<link rel="stylesheet" type="text/css" href="ie10-and-up.css">

<![endif]-->

或:

<!--[if gte IE 10]>

<link rel="stylesheet" type="text/css" href="ie10-and-up.css">

<![endif]-->

13、高于IE8的版本(IE9以及IE9以上版本)

<!--[if gt IE 8]>

<link rel="stylesheet" type="text/css" href="ie9-and-up.css">

<![endif]-->

或:

<!--[if gte IE 9]>

<link rel="stylesheet" type="text/css" href="ie9-and-up.css">

<![endif]-->

14、高于IE7的版本(IE8以及IE8以上版本)

<!--[if gt IE 7]>

<link rel="stylesheet" type="text/css" href="ie8-and-up.css">

<![endif]-->

或:

<!--[if gte IE 8]>

<link rel="stylesheet" type="text/css" href="ie8-and-up.css">

<![endif]-->

15、高于IE6的版本(IE7以及IE7以上版本)

<!--[if gt IE 6]>

<link rel="stylesheet" type="text/css" href="ie7-and-up.css">

<![endif]-->

或:

<!--[if gte IE 7]>

<link rel="stylesheet" type="text/css" href="ie7-and-up.css">

<![endif]-->

16、高于IE5.5的版本(IE6以及IE6以上版本)

<!--[if gt IE 5.5]>

<link rel="stylesheet" type="text/css" href="ie6-and-up.css">

<![endif]-->

或:

<!--[if gte IE 6]>

<link rel="stylesheet" type="text/css" href="ie6-and-up.css">

<![endif]-->

注明:以上 内容来自浏览器兼容之旅的第一站:如何创建条件样式 ,转载请注明,谢谢...

对上文的一点补充:

17、指定多种IE版本

<!--[if (IE 6)|(IE 7)|(IE 8)]>

<link rel="stylesheet" type="text/css" href="ie6-7-8.css">

<![endif]-->

原文来自http://hi.baidu.com/skay010/item/4e47a5e6fd3081374ddcaf80

功能未经测试,先留着备用。有时间再来测试下效果

优质内容筛选与推荐>>
1、C#各版本新增加功能(系列文章)
2、ssm客户管理系统的设计与实现
3、[Windows]Allow Administrator account mstsc multi login / 允许Administrator账号多用户远程登录
4、jQuery-跨域问题的处理
5、(二十九)c#Winform自定义控件-文本框(二)-HZHControls


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号