欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

css條件注釋理論及實(shí)踐源文件

 更新時(shí)間:2007年03月09日 00:00:00   作者:  
瀏覽器的條件注釋理論,用下面一段例子來解釋這個(gè)問題

(X)HTML

下面一段代碼是測(cè)試在微軟的IE瀏覽器下的條件注釋語句的效果

<!--[if IE]>
<h1>您正在使用IE瀏覽器</h1>
<![endif]-->
<!--[if IE 5]>
<h1>版本 5</h1>
<![endif]-->
<!--[if IE 5.0]>
<h1>版本 5.0</h1>
<![endif]-->
<!--[if IE 5.5]>
<h1>版本 5.5</h1>
<![endif]-->
<!--[if IE 6]>
<h1>版本 6</h1>
<![endif]-->
<!--[if IE 7]>
<h1>版本 7</h1>
<![endif]-->

下面的代碼是在非IE瀏覽器下運(yùn)行的條件注釋

<!--[if !IE]><!-->
<h1>您使用不是 Internet Explorer</h1>
<!--<![endif]-->
最終在非IE和特殊的IE瀏覽器下起作用
(或者使用 lte lt 或者 gt gte來判斷,如:
<!--[if lte IE 6]>
在IE 6下顯示的信息
<![endif]--> 
).

<!--[if IE 6]><!-->
<h1>您正在使用Internet Explorer version 6<br />
或者 一個(gè)非IE 瀏覽器</h1>
<!--<![endif]-->

From:cssplay.co.uk/menu/conditional.html" target="_blank">http://www.cssplay.co.uk/menu/conditional.html

上面提到了條件注釋,就是判斷瀏覽器類型,然后定義什么瀏覽器下顯示什么內(nèi)容。

這個(gè)dropmenu(下拉菜單)模型來自cssplay,使經(jīng)過作者多次的研究和反復(fù)的測(cè)試才做出來的。我想那這個(gè)模型來實(shí)踐一下條件注釋的原理。

先看一個(gè)最簡(jiǎn)單的模型

下面是xhtm
<div class="menu">
<ul>
<li><a class="drop" href="../menu/index.html">DEMOS
<!--[if IE 7]><!-->
</a>
<!--<![endif]-->
<!--IE7時(shí)顯示</a>標(biāo)簽-->
<table><tr><td>
<ul>
<li><a href="../menu/zero_dollars.html" title="The zero dollar ads page">zero dollars advertising page</a></li>
<li><a href="../menu/embed.html" title="Wrapping text around images">wrapping text around images</a></li>
<li><a href="../menu/form.html" title="Styling forms">styled form</a></li>
<li><a href="../menu/nodots.html" title="Removing active/focus borders">active focus</a></li>
<li><a class="drop" href="../menu/hover_click.html" title="Hover/click with no active/focus borders">hover/click with no borders</li>
<li class="upone"><a href="../menu/shadow_boxing.html" title="Multi-position drop shadow">shadow boxing</a></li>
<li><a href="../menu/old_master.html" title="Image Map for detailed information">image map for detailed information</a></li>
<li><a href="../menu/bodies.html" title="fun with background images">fun with background images</a></li>
<li><a href="../menu/fade_scroll.html" title="fade-out scrolling">fade scrolling</a></li>
<li><a href="../menu/em_images.html" title="em size images compared">em image sizes compared</a></li>
</ul>
</td></tr></table>

<!--[if lte IE 6]>
</a>
<![endif]-->
</li>
<!--IE6時(shí)顯示</a>標(biāo)簽-->
</ul>
</div>


CSS
<link rel="stylesheet" media="all" type="text/css" href="final_drop.css" />
<!--[if lte IE 6]>
<link rel="stylesheet" media="all" type="text/css" href="final_drop_ie.css" />
<![endif]-->

采用雙樣式,給ie和非ie分別定義樣式,如果IE時(shí)候,在final_drop.css基礎(chǔ)上補(bǔ)充一個(gè)final_drop_ie.css

先看看非ie下的css是怎樣定義的
.menu ul li ul {
display: none;
}
/* specific to non IE browsers */
.menu ul li:hover a {
color:#fff; 
background:#bd8d5e;
}
/*定義鼠標(biāo)滑過樣式*/
.menu ul li:hover ul {
display:block; 
position:absolute; 
top:3em;
margin-top:1px;
left:0; 
width:150px;
}


在非IE下,看到鼠標(biāo)滑過時(shí)候li包含的ul顯示了,因?yàn)檫@些瀏覽器支持li:hover用法

IE下的css
.menu ul li a:hover {
color:#fff; 
background:#bd8d5e;
}
/*當(dāng)鼠標(biāo)滑過時(shí)li包含的ul顯示*/
.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樣式,無鼠標(biāo)時(shí)間時(shí)候li包含的ul不顯示
因?yàn)?
<!--[if lte IE 6]>
</a>
<![endif]-->
所以在IE6下鼠標(biāo)滑過時(shí)候在通過a:hover來顯示那個(gè)ul內(nèi)容
而IE7下通過li:hover顯示的效果一樣

相關(guān)文章

最新評(píng)論