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
功能未经测试,先留着备用。有时间再来测试下效果
HTML条件注释用法诠释的更多相关文章
- HTML中的IE条件注释
IE条件注释是一种特殊的HTML注释,这种注释只有IE5.0及以上版本才能理解.比如普通的HTML注释是: <!--This is a comment--> 而只有IE可读的IE条件注释是 ...
- HTML在IE中的条件注释
HTML在IE中的条件注释 HTML的条件注释在IE5中被首次引入,直到IE9.一直都是简单地判定用户浏览器(IE,非IE,IE版本)的一种手段,而在IE10的标准模式下,条件注释功能被停止支持(兼容 ...
- 关于IE条件注释(译)
本文翻译自此篇文章.翻译纯属业余. 许多网站为了确保他们的站点能够在不同的浏览器上有不同的显示效果而使用特征检测,一些传统的网站使用其他技术,诸如在服务器或客户端上使用脚本去检测浏览器类型.在这里我们 ...
- 通过HTML条件注释判断IE版本的HTML语句详解<!--[if IE]> <![endif]-->
我们常常会在网页的HTML里面看到形如[if lte IE 9]……[endif]的代码,表示的是限定某些浏览器版本才能执行的语句,那么这些判断语句的规则是什么呢?请看下文: <!--[if ! ...
- 条件注释+JS实现各版本IE浏览器className
最近又开始忙了,项目中又遇到了可恶的IE Hack问题,各种Hack的看着让自己都觉得恶心,于是决定改造一番. 首先请出条件注释语句: 之前用过的条件注释 <!--[if lt IE 7]> ...
- CSS条件注释
由于浏览器版本的不同,对CSS里某些元素的解释也不一样,针对浏览器版本不同而选择不同CSS的代码,其实我们还可以利用条件注释的方法来达到类似的目的,什么是条件注释,在此简单介绍一下,无非就是一些if判 ...
- 使用条件注释判断 IE 浏览器版本
IE条件注释是一种特殊的HTML注释,这种注释只有IE5.0及以上版本才能理解.比如普通的HTML注释是: <!--This is a comment--> 而只有IE可读的IE条件注释是 ...
- IE版本判断条件注释
IE下判断IE版本的语句...[if lte IE 8]……[endif] <!--[if lte IE 6]> <![endif]--> IE6及其以下版本可见 < ...
- HTML中的IE条件注释,让低版本IE也能正常运行HTML5+CSS3网站的3种解决方案
最近的项目中,因为需要兼容IE7,IE8,IE9,解研究了IE的条件注释,顺手写下来备忘. HTML中的IE条件注释 IE条件注释是一种特殊的HTML注释,这种注释只有IE5.0及以上版本才能理解. ...
随机推荐
- QDialog 添加最大化、最小化按钮和关闭按钮,并且要正常显示
在使用QDialog时,默认情况下只有“这是什么”和“关闭”按钮(不知道为什么QT要这么做),但是我们习惯有最大化和最小化按钮.本文介绍如何在该模式下如何设置. 新建一个QDialog工程,然后打开D ...
- [jumping to the gate] 娱乐向setjmp
转载:http://tieba.baidu.com/p/1393753521 灌水的时候从goto一路拐到了setjmp, 顺便也试了试貌似这东西确实是没有析构效果的.之前并没有看过setjmp的实现 ...
- eclipse打开文件位置Open Explorer 插件
,OpenExplorer插件可以满足这个功能,可以到https://github.com/samsonw/OpenExplorer/downloads下载最新版本,将jar包放到eclipse的pl ...
- Redhat Enterprise Linux中如何关闭SELinux?
转自http://www.cnitblog.com/lywaml/archive/2005/06/21/468.html 红帽企业 Linux 4 包括了一个 SELinux 的实现.SELinux ...
- 《UNIX环境高级编程》笔记--chown,fchown和lchown函数
这三个函数都是用来更改文件的用户ID和组ID的,函数的定义如下: #include <unistd.h> int chown(const char *pathname, uid_t own ...
- SQL Serve数据库排序空值null始终前置的方法
[转:http://blog.knowsky.com/233986.htm] [sqlserver]: sqlserver 认为 null 最小. 升序排列:null 值默认排在最前. 要想排后面,则 ...
- uva 310 L--system(隐式图搜索+字符串处理)
L-system A D0L (Deterministic Lindenmayer system without interaction) system consists of a finite ...
- html5lib-python doc
http://html5lib.readthedocs.org/en/latest/ By default, the document will be an xml.etree element ins ...
- 曾经很长时间不会写的两个SQL语句(group by,having)
1.统计各部门的平均工资,平均资金(要求同时显示出部门名称,部门编号,部门总人数) SQL)),) 部门平均工资,)),) 部门平均资金 FROM EMP E RIGHT JOIN DEPT D ON ...
- JS获取地址参数
今天碰到获取地址参数的问题,所以总结了一下. 第一种情况:获取地址栏参数 function getUrlParam(name){ var reg = new RegExp("(^|& ...