div层最前面问题

micool 2008-08-25 03:08:22
<div id="menu">
<ul><li><img src="images/one_1_f.gif" /></li>
<li> <a href="aboutuse.asp">About US
<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]>
<table>
<tr>
<td><![endif]-->
</a>
<ul>
<li><a href="aboutuse.asp">About US</a></li>
<li><a href="companynewse.asp">New</a></li>
<li><a href="jobe.asp">Job</a></li>
</ul>
<!--[if lte IE 6]>
</td>
</tr>
</table>
</a><![endif]-->
</li>
<li> <a href="#">Products
<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]>
<table>
<tr>
<td><![endif]-->
</a>
<ul>
<li><a href="newProduct.asp">New Products</a></li>
<li><a href="mainProduct.asp">Main Products</a></li>
<li><a href="Advantagee.asp">Products</a></li>
<li><a href="helpfore.asp">Help</a></li>
</ul>
<!--[if lte IE 6]>
</td>
</tr>
</table>
</a><![endif]-->
</li>
<li> <a href="downloade.asp">Download</a> </li>
<li> <a href="Colleaguee.asp">Cooperation</a> </li>
<li> <a href="guestbooke.asp">Message</a> </li>
<li> <a href="contacte.asp">Contact</a> </li>
<li> <a href="bbse.asp">Forum</a> </li>
<li><img src="images/one_1_e.gif" /></li>
</ul>
</div>


用css控制的导航条
/*menu部分*/
#menu{
clear:both;
}
#menu{
margin:0;
position:relative;
width:765px!important;
}
#menu ul{

list-style:none;
}
#menu li {
position:absolute;
float:left;
position:relative;
}
#menu ul ul {
visibility:hidden;
position:absolute;
z-index:1000;
left:0px;
top:30px;
}
#menu table{
position:absolute;
left:0;
top:0;
}
#menu ul li:hover ul,#menu ul a:hover ul{
visibility:visible;
}
#menu a{
display:block;
text-align:center;
text-decoration:none;
width:100px;
height:30px;
color:#fff;
font: 12px Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
line-height:30px;
background-image:url(../images/over.gif);
}
#menu a:hover{
color:#000;
background-image:url(../images/hover.gif);
}
#menu ul ul li {
clear:both;
text-align:left;
position:absolute;
}
#menu ul ul li a{
display:block;
width:100px;
height:30px;
background-image:url(../images/hoverli.gif);
color:#fff;
}
#menu ul ul li a:hover{
background-image:url(../images/hover.gif);
color:#000;
}

但是导航条下拉的不显示在最前面 被导航下面的一个div遮掉了

position:absolute; 没用
z-index=auto;或者比较大的值也没用

因为导航条下面的这个div 因为某些元素的原因 也要 position:absolute;

怎么解决,让导航条的下拉 <li></li>为最前端的层
...全文
422 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxn19811006 2008-08-26
  • 打赏
  • 举报
回复
xuexi
HW_zxc_001 2008-08-26
  • 打赏
  • 举报
回复
up
web78dy 2008-08-26
  • 打赏
  • 举报
回复
不知道你想要的是不是这种结果:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "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">
<!--
body{
font-size:12px;
color:#999999;
}

ul#menu{
list-style:none;
margin:0;
clear:both;
width:100%;
padding:0;
font-size:12px;
text-align:left;
line-height:28px;
position:relative;


}
ul#menu ul{
list-style:none;
margin:0;
clear:both;
border:1px solid #ccc;
padding:0;
font-size:12px;
text-align:left;
line-height:28px;
float:left;

}
ul#menu li{
position:relative;
padding-left:10px;
padding-right:10px;
height:28px;
background:#f5f5f5;
float:left;
margin:0 10px;

}
ul#menu li ul li{ white-space:nowrap;}
ul#menu li ul{
position:absolute;
left:0px;
_left:0px;
top:28px;
display:none;
background:#f5f5f5;

}
ul#menu li.over{
background:#fff;

}
ul#menu li.out{
background:#f5f5f5;
}
ul#menu a{
text-decoration:none;
color:#000;
_height:0;
}
ul#menu a:link { color: #000; text-decoration: none;}
ul#menu a:hover { color: #f00; text-decoration: underline; }
-->
</style>
</head>

<body>
<ul id="menu">
<li><a href="#">About US</a>
<ul>
<li> <a href="#">About US</a> </li>
<li><a href="#">New</a></li>
<li><a href="#">Job</a></li>
</ul>
</li>
<li> <a href="#">Products</a>
<ul>
<li><a href="#">New Products</a></li>
<li><a href="#">Main Products</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Help</a></li>
</ul>
</li>
<li> <a href="downloade.asp">Download </a> </li>
<li> <a href="Colleaguee.asp">Cooperation </a> </li>
<li> <a href="guestbooke.asp">Message </a> </li>
<li> <a href="contacte.asp">Contact </a> </li>
<li> <a href="bbse.asp">Forum </a> </li>
</ul>
<script type="text/javascript">
function initMenu(event,ul){
if(!ul) ul = document.getElementById("menu");
li = ul.getElementsByTagName("li");
for(i=0;i <li.length;i++)
{
li[i].onmouseover = function(){
try{
this.className='over';
this.getElementsByTagName("ul")[0].style.display="block";
}catch(e){};
}
li[i].onmouseout = function(){
try{
this.className='out';
this.getElementsByTagName("ul")[0].style.display="none";
}catch(e){};
}
}
}
window.onload = initMenu;
</script>
</body>

</html>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧