Html 水平下拉菜单悬停
我已经从和创建了水平下拉菜单 我希望菜单如下所示: 我希望子菜单出现在右侧的父菜单上 下一步是子菜单。我们希望每个子菜单在其父菜单项悬停时显示在其右侧Html 水平下拉菜单悬停,html,css,Html,Css,我已经从和创建了水平下拉菜单 我希望菜单如下所示: 我希望子菜单出现在右侧的父菜单上 下一步是子菜单。我们希望每个子菜单在其父菜单项悬停时显示在其右侧 li ul { position: absolute; left: 149px; top: 0; display: none; } 但子菜单未显示在其父菜单的右侧,如下所示: 包含子菜单的目录项必须具有位置:相对或位置:绝对,才能使内容相对于其偏移顶部显示。删除ul隐藏列表的现有样式,并添加以下类:子下拉列表 然后添加以下CSS:
li ul {
position: absolute;
left: 149px;
top: 0;
display: none;
}
但子菜单未显示在其父菜单的右侧,如下所示:
包含子菜单的目录项必须具有位置:相对或位置:绝对,才能使内容相对于其偏移顶部显示。删除ul隐藏列表的现有样式,并添加以下类:
子下拉列表
然后添加以下CSS:
.subdrop-list {
display: none;
position: relative;
}
.subdrop-list ul {
position: absolute;
top: 0;
right: 0;
}
JSFIDLE:我希望这有帮助-只需在最后添加css即可
margin-top:80px;
只需使用
页边距顶部:35px代码>而不是顶部:0代码>将的CSS更改为页边距顶部:-41px代码>而不是顶部:0
.sidebar #nav .has_sub ul .has_sub_sub ul {
position: absolute;
left: 231px;
width: 230px;
margin-top: -41px;
display: none;
background: #efefef url("http://responsivewebinc.com/premium/macadmin/img/cream.png") repeat;
}
试试这个
水平下拉列表
//JavaScript文档
startList=函数(){
if(document.all&&document.getElementById){
navRoot=document.getElementById(“nav”);
对于(i=0;i)您的图像未加载-请从imagur以外的源重新嵌入
<!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>
<title>Horizontal Drop Down</title>
<script type="text/javascript" >
// JavaScript Document
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>
<style type="text/css">
body {
font: 11px verdana;
}
ul {
border-bottom: 1px solid #CCCCCC;
list-style: none outside none;
margin: 0;
padding: 0;
width: 150px;
}
ul li {
position: relative;
}
li ul {
display: none;
left: 149px;
position: absolute;
top: 0;
}
ul li a {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: none repeat scroll 0 0 #FFFFFF;
border-color: #CCCCCC #CCCCCC -moz-use-text-color;
border-image: none;
border-style: solid solid none;
border-width: 1px 1px 0;
color: #777777;
display: block;
padding: 5px;
text-decoration: none;
}
* html ul li {
float: left;
height: 1%;
}
* html ul li a {
height: 1%;
}
li:hover ul, li.over ul {
display: block;
}
</style>
</head>
<body>
<ul id="nav">
<li><a href="#">Dashboard</a></li>
<li><a href="#">Catalog</a>
<ul>
<li><a href="#">Attribute</a></li>
<li><a href="#">Attribute Group</a></li>
</ul>
</li>
</ul>
</body>
</html>