出现上面情况的参考代码:
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html>
head>
title>Css Javascript Demotitle>
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">aaaaaaabr>bbbbbbbbr>cccccccdiv>
br/>
select id="ddlTest">option>test0option>test1option>test2option>test3select>
html>
For IE6, in fact, we are not without solutions. Although we have to admit that this method is very "frustrating", this is currently the most effective method. That is to add an iframe above the drop-down list, and then let the div layer float above the iframe, so that the div can "cover" the drop-down list. If you want to ask "why", then, first of all, congratulations, you are a good classmate, unlike many people who only look for solutions on the Internet instead of knowledge (for example, I-_-b...), and then I will tell You, there is no reason for this, this is the weird analysis of IE6. If you must ask why, I can only tell you that in IE6, if there are only div and select, no matter how your z-index is set, the div layer will always be trampled by the select tag, while the iframe can crawl to the select. Therefore, the following method can solve the problem because the iframe is above the select, and the div rides on the iframe and climbs to the select. It is a bit like this: A Pekingese dog (div ) usually gets stepped on and bullied by the big wolf dog (select). On this day, Jingba’s owner (iframe) hugged Jingba and stepped on the big wolf dog’s soles. At this time, Jingba was naturally on top of the big wolf dog.扯远了,给出解决方案代码:
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html>
head>
title>Css Javascript Demotitle>
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中将这句话放出来,你就会明白京叭、狼狗、主人的比喻*/
}
#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">aaaaaaabr>bbbbbbbbr>cccccccdiv>
br/>
select id="ddlTest">option>test0option>test1option>test2option>test3select>
html>