網上有兩種解決辦法:
◆當浮動層DIV出現的時候,用JS將select隱藏,當浮動層DIV消失的時候select恢復出現。這種方法早期用的比較多,這裡不多介紹。
◆ 用select同級別元素:iframe標簽, 然後用實際的浮動層DIV和iframe放在一起。間接的使DIV遮住了select。
正確的代碼:
- "http://www.w3.org/TR/xhtml1/DTD/xHtml1-transitional.dtd">
- <Html XMLns="http://www.w3.org/1999/xHtml">
- <head>
- <meta http-equiv="Content-Type" content="text/Html; charset=gb2312" />
- <title>無標題文檔title>
- <style type="text/CSS">
- #warp { position:absolute; top:10px; left:26px; width:200px; height:200px;}
- .box { position:absolute; top:0; left:0; width:200px;
- height:200px; background:#FDF3D9; border:1px solid #EEAC53}
- .box iframe {width:400px; height:400px; z-index:-1}
- style>
- head>
- <body>
- <DIV id="warp">
- <iframe frameborder="0">iframe>
- <DIV class="box">dfsagdsaDIV>
- DIV>
- <form id="form1" name="form1" method="post" action="">
- <label>
- <select name="select" id="select">
- <option>測試選項option>
- <option>測試選項2option>
- <option>測試選項3option>
- select>
- label>
- form>
- body>
- Html>
[提示:你可先修改部分代碼,再按運行]
【編輯推薦】