層蓋住下拉列表框問題解決方案
IE6真的讓人很郁悶。但是就目前而言,我們還是不能放棄對(duì)IE6的兼容。從下面的我的blog訪問統(tǒng)計(jì)分析數(shù)據(jù)來看,使用IE6的還是占有絕對(duì)主流的。
本來想順便說說web標(biāo)準(zhǔn)中這個(gè)“標(biāo)準(zhǔn)”到底是個(gè)什么東西,但是發(fā)現(xiàn),還是明日另起一篇吧。因?yàn)檫@個(gè)不是“順便說說”就能說清楚的。我們今天還是不如這個(gè)正題——如何讓層蓋住下拉列表框?
非常郁悶或者非常幸運(yùn)的說一下:這個(gè)問題只會(huì)出現(xiàn)IE7之前那些對(duì)web標(biāo)準(zhǔn)支持不好的瀏覽器中(例如現(xiàn)在非常主流的IE6 -_-b... ),IE7和FF都不會(huì)出現(xiàn)這個(gè)問題。截圖為證:
<html>
<head>
<title>Css Javascript Demo</title>
<meta name="Generator" content="EditPlus"/>
<meta name="Author" content="JustinYoung"/>
<meta name="Keywords" content="CssStandard JavascriptDemo,B/S,JustinYoung"/>
<meta name="Description" content="This demo from JustinYoung's Blog:Yes!B/S!"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
#divUp{
z-index:99;
position:absolute;
background-color:red;
width:100;
height:18;
overflow:hidden;
height:60px;
}
#ddlTest{
width:200;
z-index:1;
}
</style>
<body>
<div id="divUp">aaaaaaa<br>bbbbbbb<br>ccccccc</div>
<br/>
<select id="ddlTest"><option>test0<option>test1<option>test2<option>test3</select>
</html>
對(duì)于IE6,其實(shí)我們也并不是沒有辦法,雖然我們不得不承認(rèn)這個(gè)辦法很“挫”,但是這個(gè)是目前最有效的辦法。那就是在下拉列表上方加一個(gè)iframe,然后讓div層浮在iframe上方,這樣,就能使div“蓋住”下拉列表。如果你要問“為什么”,那么,首先恭喜你,你是個(gè)好同學(xué),不像很多人只在網(wǎng)上找解決辦法,而不是找知識(shí)(例如我-_-b...),然后我會(huì)告訴你,這個(gè)沒有為什么,這個(gè)就是IE6的詭異解析。如果一定要問為什么,我只能告訴你,在IE6看來,如果只有div和select,無論你的z-index怎么設(shè)置,div的層永遠(yuǎn)被會(huì)被select標(biāo)簽踩在腳底,而iframe則可以爬到select頭上,所以,下面的方法之所以能解決問題,是因?yàn)閕frame在select上方,而div搭著iframe的順風(fēng)車也爬到了select的頭上,這有點(diǎn)像這樣:一條京叭狗(div)平時(shí)老是被大狼狗(select)踩到腳底欺負(fù),這天,京叭的主人(iframe)抱著京叭把大狼狗踩到了腳底。這時(shí)候京叭自然就在大狼狗的頭上了。扯遠(yuǎn)了,給出解決方案代碼:
<html>
<head>
<title>Css Javascript Demo</title>
<meta name="Generator" content="EditPlus"/>
<meta name="Author" content="JustinYoung"/>
<meta name="Keywords" content="CssStandard JavascriptDemo,B/S,JustinYoung"/>
<meta name="Description" content="This demo from JustinYoung's Blog:Yes!B/S!"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
body{
font-size:small;
}
#zindexDiv{
position:absolute;
z-index:50;
width:expression(this.nextSibling.offsetWidth);
height:expression(this.nextSibling.offsetHeight);
top:expression(this.nextSibling.offsetTop);
left:expression(this.nextSibling.offsetLeft);
/*background-color:green;在ff中將這句話放出來,你就會(huì)明白京叭、狼狗、主人的比喻*/
}
#divUp{
z-index:99;
position:absolute;
background-color:red;
width:100;
height:18;
overflow:hidden;
height:60px;
}
#ddlTest{
width:200;
z-index:1;
}
</style>
<body>
<iframe id="zindexDiv" frameborder="0"></iframe>
<div id="divUp">aaaaaaa<br>bbbbbbb<br>ccccccc</div>
<br/>
<select id="ddlTest"><option>test0<option>test1<option>test2<option>test3</select>
</html>
keyword:層 列表框,div和列表框,列表框蓋住層,怎么讓層蓋住列表框,列表框和層,下列列表框,如何用層蓋住下拉列表框
相關(guān)文章
CSS優(yōu)化2-(常用CSS縮寫語法總結(jié))
CSS優(yōu)化2-(常用CSS縮寫語法總結(jié))...2007-05-05關(guān)于filter濾鏡應(yīng)用于圖片的兩種創(chuàng)意
關(guān)于filter濾鏡應(yīng)用于圖片的兩種創(chuàng)意...2006-12-12一點(diǎn)小小的創(chuàng)意css鼠標(biāo)放上去則顯示電話號(hào)碼
一點(diǎn)小小的創(chuàng)意css鼠標(biāo)放上去則顯示電話號(hào)碼...2007-10-10