如何让DIV层盖住下拉列表框? 问题解决方案

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="ProgId" content="Word.Document"> <meta name="Generator" content="Microsoft Word 11"> <meta name="Originator" content="Microsoft Word 11"> <link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"> <link rel="Edit-Time-Data" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso"> <!--[if !mso]> <style> v/:* {behavior:url(#default#VML);} o/:* {behavior:url(#default#VML);} w/:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></smarttagtype><smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="chsdate" downloadurl=""></smarttagtype><smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="chmetcnv" downloadurl=""></smarttagtype><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object> <style> st1/:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="1029"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]-->

如何让DIV层盖住下拉列表框? 问题解决方案.

参考:http://www.cnblogs.com/JustinYoung/archive/<chsdate year="2007" month="7" day="18" islunardate="False" isrocdate="False" w:st="on">2007/07/18</chsdate>/821868.html

首先,我们不得不承认IE7以前的IE系列浏览器对web标准支持的真的很差。IE6的诡异解析模式让一些开始学习web标准的朋友老是碰到不能理解的问题。特别是这个IE6IE7过渡的是非年代。IE6真的让人很郁闷。但是就目前而言,我们还是不能放弃对IE6的兼容。从下面的我的blog访问统计分析数据来看,使用IE6的还是占有绝对主流的。
<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style='width:387pt; height:133.5pt'> <v:imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image001.png" o:href="http://images.cnblogs.com/cnblogs_com/justinyoung/2007/vistorIE.png"/> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->
本来想顺便说说web标准中这个标准到底是个什么东西,但是发现,还是明日另起一篇吧。因为这个不是顺便说说就能说清楚的。我们今天还是不如这个正题——如何让层盖住下拉列表框?

非常郁闷或者非常幸运的说一下:这个问题只会出现IE7之前那些对web标准支持不好的浏览器中(例如现在非常主流的IE6 -_-b...,IE7FF<!--[if gte vml 1]><v:shape id="_x0000_s1027" type="#_x0000_t75" alt="" style='position:absolute;left:0;text-align:left; margin-left:-45pt;margin-top:39pt;width:194.25pt;height:159pt;z-index:2; mso-wrap-distance-left:0;mso-wrap-distance-top:0;mso-wrap-distance-right:0; mso-wrap-distance-bottom:0;mso-position-horizontal:absolute; mso-position-horizontal-relative:text;mso-position-vertical:absolute; mso-position-vertical-relative:line' o:allowoverlap="f"> <v:imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image003.png" o:title="updivinIE6"/> <w:wrap type="square"/> </v:shape><![endif]--><!--[endif]-->都不会出现这个问题。

出现上面情况的参考代码:

<!DOCTYPEhtmlPUBLIC"-//W<chmetcnv unitname="C" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">3C</chmetcnv>//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>CssJavascriptDemo</title>
<metaname="Generator"content="EditPlus"/>
<metaname="Author"content="JustinYoung"/>
<metaname="Keywords"content="CssStandardJavascriptDemo,B/S,JustinYoung"/>
<metaname="Description"content="ThisdemofromJustinYoung'sBlog:Yes!B/S!"/>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<styletype="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>
<divid="divUp">aaaaaaa<br>bbbbbbb<br>ccccccc</div>
<br/>
<selectid="ddlTest"><option>test0<option>test1<option>test2<option>test3</select>
</html>

<!--[if gte vml 1]><v:shape id="_x0000_s1026" type="#_x0000_t75" alt="" style='position:absolute;margin-left:9pt;margin-top:-23.4pt;width:60.75pt; height:64.5pt;z-index:1;mso-wrap-distance-left:0;mso-wrap-distance-top:0; mso-wrap-distance-right:0;mso-wrap-distance-bottom:0; mso-position-horizontal:absolute;mso-position-horizontal-relative:text; mso-position-vertical:absolute;mso-position-vertical-relative:line' o:allowoverlap="f"> <v:imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image007.png" o:title="div_select"/> <w:wrap type="square"/> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->
对于IE6,其实我们也并不是没有办法,虽然我们不得不承认这个办法很,但是这个是目前最有效的办法。那就是在下拉列表上方加一个iframe,然后让div层浮在iframe上方,这样,就能使div“盖住下拉列表。如果你要问为什么,那么,首先恭喜你,你是个好同学,不像很多人只在网上找解决办法,而不是找知识(例如我-_-b...),然后我会告诉你,这个没有为什么,这个就是IE6的诡异解析。如果一定要问为什么,我只能告诉你,在IE6看来,如果只有divselect,无论你的z-index怎么设置,div的层永远被会被select标签踩在脚底,而iframe则可以爬到select头上,所以,下面的方法之所以能解决问题,是因为iframeselect上方,而div搭着iframe的顺风车也爬到了select的头上,这有点像这样:一条京叭狗(div)平时老是被大狼狗(select)踩到脚底欺负,这天,京叭的主人(iframe)抱着京叭把大狼狗踩到了脚底。这时候京叭自然就在大狼狗的头上了。扯远了,给出解决方案代码:

<!DOCTYPEhtmlPUBLIC"-//W<chmetcnv unitname="C" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">3C</chmetcnv>//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>CssJavascriptDemo</title>
<metaname="Generator"content="EditPlus"/>
<metaname="Author"content="JustinYoung"/>
<metaname="Keywords"content="CssStandardJavascriptDemo,B/S,JustinYoung"/>
<metaname="Description"content="ThisdemofromJustinYoung'sBlog:Yes!B/S!"/>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<styletype="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中将这句话放出来,你就会明白京叭、狼狗、主人的比喻*/
}

#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>
<iframeid="zindexDiv"frameborder="0"></iframe>
<divid="divUp">aaaaaaa<br>bbbbbbb<br>ccccccc</div>
<br/>
<selectid="ddlTest"><option>test0<option>test1<option>test2<option>test3</select>
</html>

另外的一种解决办法:实验通过。原理是在div块中添加一个不可见的iframe

<!DOCTYPE HTML PUBLIC "-//W<chmetcnv unitname="C" sourcevalue="3" hasspace="False" negative="False" numbertype="1" tcsc="0" w:st="on">3C</chmetcnv>//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE> New Document </TITLE>

<<place w:st="on">META</place> NAME="Generator" CONTENT="EditPlus">

<<place w:st="on">META</place> NAME="Author" CONTENT="">

<<place w:st="on">META</place> NAME="Keywords" CONTENT="">

<<place w:st="on">META</place> NAME="Description" CONTENT="">

</HEAD>

<BODY>

<div id="menu" style="position:absolute; visibility:hidden; top:20px; left:20px;

width:100px; height:200px; background-color:#6699cc;">

<table>

<tr><td>item 1</td></tr>

<tr><td>item 2</td></tr>

<tr><td>item 3</td></tr>

<tr><td>item 4</td></tr>

<tr><td>item 5</td></tr>

</table>

<iframe src="" style="position:absolute; visibility:inherit; top:0px; left:0px; z-index:-1; filter='progidXImageTransform.Microsoft.Alpha(style=0,opacity=0)';"></iframe>

</div>

<a href="#" οnclick="document.getElementById('menu').style.visibility='visible';">menu</a>

<form>

<select><option>A form selection list</option></select>

</form>

</BODY>

</HTML>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值