QUOTE:
这里是正常的html代码
这里XXX是一些特定的东东,在此列表几个出来,详细介绍各自的含义:
/ 如果浏览器是IE /
/ 如果浏览器是IE 5 的版本
/
/ 如果浏览器是IE 6 的版本
/
/ 如果浏览器是IE 7 的版本
/
……
上面是几个常用的判断IE浏览器版本的语法,下面再来介绍一下相对比较少用的逻辑判断的参数:
有几个参数:lte,lt,gte,gt及!
各自的详细解释如下:
QUOTE:
lte:就是Less
than or equal to的简写,也就是小于或等于的意思。
lt :就是Less than的简写,也就是小于的意思。
gte:就是Greater than or equal to的简写,也就是大于或等于的意思。
gt :就是Greater than的简写,也就是大于的意思。
!
:就是不等于的意思,跟javascript里的不等于判断符相同,^0^
也写几条例句吧:
QUOTE:
/ 如果IE版本大于5.5
/
/ 如果IE版本小于等于6
/
/ 如果浏览器不是IE /
……
看到这里相信大家都已经明白了条件注释的用法了,OK,那来举个例子吧:
href=”css.css” />
/>
–>
/>
详细使用方法已经介绍完了,不得不提的一点就是:
条件注释是在IE5.0/Win以后才被IE支持的,对于IE5以前的浏览器是无效的,不过,应该没什么人还在使用IE4的版本了吧。^0^
浏览器的条件注释理论,用下面一段例子来解释这个问题
(X)HTML
下面一段代码是测试在微软的IE浏览器下的条件注释语句的效果
QUOTE:
您正在使用IE浏览器
版本
5
版本
5.0
版本
5.5
版本
6
版本
7
下面的代码是在非IE浏览器下运行的条件注释
QUOTE:
!IE]>
您使用不是 Internet
Explorer
最终在非IE和特殊的IE浏览器下起作用
(或者使用 lte lt 或者 gt gte来判断,如:
QUOTE:
在IE 6下显示的信息
).
6]>
您正在使用Internet Explorer version
6
或者 一个非IE 浏览器
From:cssplay.co.uk/menu/conditional.html”
target=”_blank”>http://www.cssplay.co.uk/menu/conditional.html
上面提到了条件注释,就是判断浏览器类型,然后定义什么浏览器下显示什么内容。
这个dropmenu(下拉菜单)模型来自cssplay,使经过作者多次的研究和反复的测试才做出来的。我想那这个模型来实践一下条件注释的原理。
先看一个最简单的模型
下面是xhtm
QUOTE:
href=”../menu/index.html”>DEMOS
标签–>
href=”../menu/zero_dollars.html” title=”The zero dollar ads
page”>zero dollars advertising
page
href=”../menu/embed.html” title=”Wrapping text around
images”>wrapping text around
images
href=”../menu/form.html” title=”Styling
forms”>styled
form
href=”../menu/nodots.html” title=”Removing active/focus
borders”>active
focus
href=”../menu/hover_click.html” title=”Hover/click with no
active/focus borders”>hover/click with no
borders
href=”../menu/shadow_boxing.html” title=”Multi-position drop
shadow”>shadow
boxing
href=”../menu/old_master.html” title=”Image Map for detailed
information”>image map for detailed
information
href=”../menu/bodies.html” title=”fun with background
images”>fun with background
images
href=”../menu/fade_scroll.html” title=”fade-out
scrolling”>fade
scrolling
href=”../menu/em_images.html” title=”em size images
compared”>em image sizes
compared
标签–>
CSS
href=”final_drop.css” />
href=”final_drop_ie.css” />
采用双样式,给ie和非ie分别定义样式,如果IE时候,在final_drop.css基础上补充一个final_drop_ie.css
先看看非ie下的css是怎样定义的
.menu ul li ul {
display: none;
}
.menu ul li:hover a {
color:#fff;
background:#bd8d5e;
}
.menu ul li:hover ul {
display:block;
position:absolute;
top:3em;
margin-top:1px;
left:0;
width:150px;
}
在非IE下,看到鼠标滑过时候li包含的ul显示了,因为这些浏览器支持li:hover用法
IE下的css
.menu ul li a:hover {
color:#fff;
background:#bd8d5e;
}
.menu ul li a:hover ul {
display:block;
position:absolute;
top:3em;
left:0;
background:#fff;
margin-top:0;
marg\in-top:1px;
}
继承上面的final_drop.css样式,无鼠标时间时候li包含的ul不显示
因为
所以在IE6下鼠标滑过时候在通过a:hover来显示那个ul内容
————————————————————————————–
IE]>
You are using
Internet
Explorer.
!IE]>
You are not
using Internet
Explorer.
7]>
Welcome to
Internet Explorer
7!
7)]>
You are not
using version
7.
7]>
You are using IE
7 or
greater.
5)]>
You are using
IE 5 (any
version).
7)]>
You are using
IE 5.5 or IE
6.
5.5]>
Please upgrade
your version of Internet
Explorer.