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及以上版本才能理解. ...
随机推荐
- [Ioi2007]Miners 矿工配餐(BZOJ1806)
[Ioi2007]Miners 矿工配餐 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 214 Solved: 128 Description 现有两 ...
- Codeforces 474D Flowers
http://codeforces.com/problemset/problem/474/D 思路:F[i]=F[i-1]+(i>=K)F[i-k] #include<cstdio> ...
- poj2975--Nim
题意:对于一个给定的取石子游戏,有多少种先手策略获胜? Ans:若无法获胜,则输出0. 若能获胜我们只要找到一堆石子,使得我们能取它的一部分让总和的异或和变为0.我们先将整个游戏的值异或起来为s 则a ...
- PLSQL 循环示例
<pre name="code" class="sql"><pre name="code" class="sql ...
- Shell函数返回值、删除函数、在终端调用函数
Shell 也支持函数.Shell 函数必须先定义后使用. Shell 函数的定义格式如下: function_name () { list of commands [ return value ] ...
- BufferedReader的ready与readLine使用,以及Premature EOF异常
我的个人主页:http://www.foreyou.net 有些人在读取服务器端返回的数据的时候,使用了BufferedReader类的ready: while(reader.ready()) { / ...
- Gym 100570E : Palindrome Query
De Prezer loves palindrome strings. A string s1s2...sn is palindrome if and only if it is equal to i ...
- 用户登陆,退出等基本Action
用户登陆页面user_login.jsp对应action为login.do: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transiti ...
- Hibernate(三)——框架中的关系映射
在设计数据库时我们会考虑,表与表之间的关系,例如我们前边经常提到的一对一,一对多,多对多关系,在数据库中我们通过外键,第三张表等来实现这些关系.而Hibernate时间实体类和数据库中的表进行的映射, ...
- Python模块学习笔记— —time与datatime
Python提供了多个内置模块用于操作日期时间.像calendar,time,datetime.首先对time模块中最经常使用的几个函数作一个介绍,它提供的接口与C标准库time.h基本一致.然后再介 ...