自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

解決DIV在IE6下無法遮蓋select

開發(fā) 前端
本文和大家討論一下關(guān)于select元素的一個(gè)問題,那就是一般DIV浮層在IE6下無法遮蓋select標(biāo)簽,但是IE7和Firefox下DIV都可以遮住select標(biāo)簽。

你對(duì)DIV浮層在IE6下無法遮蓋select標(biāo)簽是否了解,這里和大家一起討論一下,其實(shí)很早以前我就碰到過關(guān)于select元素的問題,但是為什么IE7和FF下DIV都可以遮住select標(biāo)簽,本文會(huì)為你揭秘。

JavaScript巧解IE6 IE7 IE8兼容問題

這次討論一下關(guān)于select元素的一個(gè)問題,其實(shí)很早以前我就碰到過關(guān)于select元素的問題,這次做網(wǎng)站又被問到同樣的問題,就是:一般DIV浮層在IE6下無法遮蓋selectaspxhome.com/search.asp?keyword=%b1%ea%c7%a9" target=_blank>標(biāo)簽,IE7和FF下DIV都可以遮住select標(biāo)簽。

列舉個(gè)簡(jiǎn)單的實(shí)例闡述問題:

 

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <html xmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  6. <title>無標(biāo)題文檔title> 
  7. <style type="text/CSS"> 
  8. #warp { position:absolute; top:10px; left:26px; width:200px; height:200px;}  
  9. .box { position:absolute; top:0; left:0; width:200px;   
  10.  
  11. height:200px; background:#FDF3D9; border:1px solid #EEAC53}  
  12. style> 
  13. head> 
  14.  
  15. <body> 
  16. <DIV id="warp"> 
  17.   <DIV class="box">dfsagdsaDIV> 
  18. DIV> 
  19. <form id="form1" name="form1" method="post" action=""> 
  20. <label> 
  21. <select name="select" id="select"> 
  22.   <option>測(cè)試選項(xiàng)option> 
  23.   <option>測(cè)試選項(xiàng)2option> 
  24.   <option>測(cè)試選項(xiàng)3option> 
  25. select> 
  26. label> 
  27. form> 
  28. body> 
  29. html> 
  30.  

 [提示:你可先修改部分代碼,再按運(yùn)行]

DIV在IE6下無法遮蓋select,原因是在IE6下,瀏覽器將select元素視為窗口級(jí)元素,這時(shí)DIV或者其它的普通元素?zé)o論z-index設(shè)置的多高都是無法遮住select元素的。#p#

網(wǎng)上有兩種解決辦法:

◆當(dāng)浮動(dòng)層DIV出現(xiàn)的時(shí)候,用JS將select隱藏,當(dāng)浮動(dòng)層DIV消失的時(shí)候select恢復(fù)出現(xiàn)。這種方法早期用的比較多,這里不多介紹。

◆ 用select同級(jí)別元素:iframe標(biāo)簽, 然后用實(shí)際的浮動(dòng)層DIV和iframe放在一起。間接的使DIV遮住了select。

正確的代碼:

  1.  
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <html xmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  6. <title>無標(biāo)題文檔title> 
  7. <style type="text/CSS"> 
  8. #warp { position:absolute; top:10px; left:26px; width:200px; height:200px;}  
  9. .box { position:absolute; top:0; left:0; width:200px;   
  10.  
  11. height:200px; background:#FDF3D9; border:1px solid #EEAC53}  
  12. .box iframe {width:400px; height:400px; z-index:-1}  
  13. style> 
  14. head> 
  15.  
  16. <body> 
  17. <DIV id="warp"> 
  18.   <iframe frameborder="0">iframe> 
  19.   <DIV class="box">dfsagdsaDIV> 
  20. DIV> 
  21. <form id="form1" name="form1" method="post" action=""> 
  22. <label> 
  23. <select name="select" id="select"> 
  24.   <option>測(cè)試選項(xiàng)option> 
  25.   <option>測(cè)試選項(xiàng)2option> 
  26.   <option>測(cè)試選項(xiàng)3option> 
  27. select> 
  28. label> 
  29. form> 
  30. body> 
  31. html> 
  32.  
  33.  

[提示:你可先修改部分代碼,再按運(yùn)行]

【編輯推薦】

  1. 深入探究IE8和IE7的24個(gè)區(qū)別
  2. 探究IE8與IE7具體功能中窗口功能按鈕的變化
  3. 剖析Margin和Padding屬性中四個(gè)值的先后順序及區(qū)別
  4. 九步輕松解決IE6的各種疑難雜癥
  5. 技術(shù)前沿 一段JS代碼輕松解決IE6-IE8的兼容性問題

 

責(zé)任編輯:佚名 來源: aspxhome.com
相關(guān)推薦

2010-08-19 15:04:26

IE6DIV

2010-08-18 15:41:38

IE6E7Firefox

2010-08-19 15:40:34

DIVIE6

2010-08-19 09:29:26

hoverIE6

2010-09-02 16:18:33

CSSDIVIE6

2010-08-25 11:23:31

IE6margin

2010-10-08 14:39:43

IE6DIVIE7

2010-08-27 15:44:47

2010-08-18 16:10:35

IE6CSS

2010-08-18 15:22:28

IE6IE7Firefox

2010-08-27 14:55:23

IE6IE7IE8

2010-08-18 16:18:59

IE6CSS

2009-08-14 09:20:40

抵制IE6

2010-08-27 15:38:21

兼容IE6IE7

2010-08-30 09:35:35

IE6IE7Firefox

2010-08-18 16:42:47

IE6CSSDIV

2010-02-01 08:41:23

GoogleIE6

2010-08-18 09:55:38

IE6

2010-08-18 14:32:07

IE6IE7IE8

2010-09-15 14:22:05

IE6position
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)