破解天下论坛's Archiver

wumingxiaozu 发表于 2007-10-17 13:06

[分享]解决下拉列表穿透层的bug[2007-10-17]

使用过层来实现菜单的程序员可能都会碰到过这样一个问题,就是层放在下拉列表上时会穿透层,无论你怎样把层的z-index属性设得多大结果还是一样。造成这样的原因是因为IE 在解释下拉列表的时候它的优先级会比层高,这是无法用z-index来解决的。

解决的办法是通过在层里加上一个iframe,并把这个IFRAME设置成是浮动且它的z-index比层低,这样子的话就可以把下拉列表挡住而又不会盖过层。原理是因为iframe的优先级会比下拉列表高。

我们具体来看一个例子。
这里要注意的一个是iframe里的一个属性:frameborder,如果没有设置这个属性为no的话,层的最外面会有一个边框。另外的是要把iframe设为浮动的,当然宽及高度都是100%的占满整个层,这样才能盖住有可能给下拉列表穿透的可能.
[code]

<html>
<div style="position:absolute;width=300px;height=300px;background-color:red">

<!--这个iframe要放在层的其它任何内容的最前面,为什么?试试把它放到最后面就知道了-->
<iframe frameBorder=no  style ="position:absolute; left:0; z-index:-1; border-Style:none;width=100%; height=100%;"></iframe>

<table width=200px border=1>
<a href="void(0)">

<!--Firefox和Netscape似乎在tr中是不支技cursor这个样式-->
<tr onmouseover="javascript:this.style.backgroundColor='red';this.style.cursor='hand'" onmouseout="javascript:this.style.backgroundColor='white'" ><td>&nbsp;</td><td ><a href="#">adadf</a></td></tr></a>
<tr onmouseover="javascript:this.style.backgroundColor='red';this.style.cursor='hand'" onmouseout="javascript:this.style.backgroundColor='white'" ><td>&nbsp;</td><td><a href="#">adadf</a></td></tr>
<tr onmouseover="javascript:this.style.backgroundColor='red';this.style.cursor='hand'" onmouseout="javascript:this.style.backgroundColor='white'" ><td>&nbsp;</td><td>adadf</td></tr>
</table>

</div>

<select>
<option>New Text Document</option>
<option>1</option>
<option>2</option>
</select>
</htm>
[/code]

bonsh 发表于 2008-8-5 16:08

我要把这个帖子一直往上顶,往上顶!顶到所有人都看到为止

00917x 发表于 2008-8-17 15:59

如此佳作,不顶说不过去,楼下的继续顶,直到把宇宙顶穿

polepole 发表于 2008-8-22 02:59

哈哈 支持啊 可以换头像咯哦,不过现在也蛮不错的。

wish 发表于 2008-8-28 06:59

留个脚印,嘻嘻,脚有点臭```````

lw_0210 发表于 2008-8-29 16:59

女人啊真是那句话~~~无理占三分~~忘记怎么说了 呵呵 ~~你帮我想想

xcgseoga 发表于 2008-9-6 11:48

Chinese girls

Sometimes if you are REALLY desperate [url=http://www.shanghai-escort.com][b]shanghai escort[/b][/url], Our services are based on friendship and companionship;  cocktail dates, dining dates, overnight liaisons and travel companion from an hour to an evening or even longer duration.and the girl REALLY needs the cash, or if you had made a good impression on her, you can negotiate sex with her.

The price varies from [url=http://hi.baidu.com/escort520]shanghai escort[/url] $100 USD and up. I don't recommend soliciting sex under any circumstances because of VDs and you will end up hurting someone other than yourself if you are in an existing relationship. If that is what you want however you should be consider going to dance clubs rather than Gentlemen clubs because there are usually more prostitutes at dance clubs.

[url=http://blog.ccidnet.com/blog.php?uid=242959]shanghai escort[/url]

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.