您好我正在制作菜单和子菜单。我想在菜单项悬停时打开子菜单,但它没有打开!它想知道你是否可以帮助我
.womendress: hover > .menu1 {
display: block;
}
.menu1 {
display: none;
position: relative;
float: right;
width: 500%;
height: 300px;
right: 0px;
top : 50px;
z-index: 10;
}

<nav>
<ul>
<li class="womendress"> پوشاک زنانه
<ul class="menu1">
<li class="tshirt">تیشرت </li>
<li>شلوار</li>
<li>پیراهن</li>
<li>سارافون</li>
</ul>
</li>
<li> تخفیفات </li>
</ul>
</nav>
&#13;
答案 0 :(得分:1)
悬停规则中.womandress:
和hover
之间有空格 - 删除它。除此之外,子菜单的设置看起来有点不切实际......(应该有position: absolute
,没有float
,宽度等等。)
答案 1 :(得分:0)
@charset "UTF-8";
/* Base Styles */
#cssmenu > ul,
#cssmenu > ul li,
#cssmenu > ul ul {
list-style: none;
margin: 0;
padding: 0;
}
#cssmenu > ul {
position: relative;
z-index: 597;
}
#cssmenu > ul li {
float: left;
min-height: 1px;
line-height: 1.3em;
vertical-align: middle;
}
#cssmenu > ul li.hover,
#cssmenu > ul li:hover {
position: relative;
z-index: 599;
cursor: default;
}
#cssmenu > ul ul {
visibility: hidden;
position: absolute;
top: 100%;
left: 0;
z-index: 598;
width: 100%;
}
#cssmenu > ul ul li {
float: none;
}
#cssmenu > ul ul ul {
top: 1px;
left: 99%;
}
#cssmenu > ul li:hover > ul {
visibility: visible;
}
/* Align last drop down RTL */
#cssmenu > ul > li.last ul ul {
left: auto !important;
right: 99%;
}
#cssmenu > ul > li.last ul {
left: auto;
right: 0;
}
#cssmenu > ul > li.last {
text-align: right;
}
#cssmenu.align-center > ul > li {
float: none;
display: inline-block;
}
#cssmenu.align-center > ul {
text-align: center;
font-size: 0;
}
#cssmenu > ul > li {
font-size: 14px;
display: block;
}
#cssmenu ul ul {
text-align: left;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu.align-right > ul ul ul {
top: 1px;
left: auto;
right: 99%;
}
/* Theme Styles */
#cssmenu > ul {
border-top: 4px solid #3fa338;
font-family: Calibri, Tahoma, Arial, sans-serif;
background: #1e1e1e;
background: -moz-linear-gradient(top, #1e1e1e 0%, #040404 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #1e1e1e), color-stop(100%, #040404));
background: -webkit-linear-gradient(top, #1e1e1e 0%, #040404 100%);
background: linear-gradient(top, #1e1e1e 0%, #040404 100%);
width: auto;
zoom: 1;
}
#cssmenu > ul:before {
content: '';
display: block;
}
#cssmenu > ul:after {
content: '';
display: table;
clear: both;
}
#cssmenu > ul li a {
display: inline-block;
padding: 10px 22px;
}
#cssmenu > ul > li.active,
#cssmenu > ul > li.active:hover {
background-color: #3fa338;
}
#cssmenu > ul > li > a:link,
#cssmenu > ul > li > a:active,
#cssmenu > ul > li > a:visited {
color: white;
}
#cssmenu > ul > li > a:hover {
color: white;
}
#cssmenu > ul ul ul {
top: 0;
}
#cssmenu > ul li li {
background-color: white;
border-bottom: 1px solid #EBEBEB;
font-size: 12px;
}
#cssmenu > ul li.hover,
#cssmenu > ul li:hover {
background-color: #F5F5F5;
}
#cssmenu > ul > li.hover,
#cssmenu > ul > li:hover {
background-color: #3fa338;
-webkit-box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
-moz-box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
#cssmenu > ul a:link,
#cssmenu > ul a:visited {
color: #9A9A9A;
text-decoration: none;
}
#cssmenu > ul a:hover {
color: #9A9A9A;
}
#cssmenu > ul a:active {
color: #9A9A9A;
}
#cssmenu > ul > li > a {
font-size: 14px;
}
#cssmenu > ul ul {
border: 1px solid #CCC \9;
-webkit-box-shadow: 0 0px 2px 1px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0px 2px 1px rgba(0, 0, 0, 0.15);
box-shadow: 0 0px 2px 1px rgba(0, 0, 0, 0.15);
width: 150px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Icon Library -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="cssmenu" class="align-right">
<ul>
<li class="active"><a href="#" target="_blank"><i class="fa fa-fw fa-home"></i> Home</a></li>
<li><a href="#"><i class="fa fa-fw fa-bars"></i> پوشاک زنانه</a>
<ul>
<li><a href="#">تیشرت</a>
<ul>
<li><a href="#">S</a></li>
<li><a href="#">M</a></li>
<li><a href="#">L</a></li>
</ul>
</li>
<li><a href="#">شلوار</a>
<ul>
<li><a href="#">S</a></li>
<li><a href="#">M</a></li>
<li><a href="#">L</a></li>
</ul>
</li>
<li><a href="#">پیراهن</a>
<ul>
<li><a href="#">S</a></li>
<li><a href="#">M</a></li>
<li><a href="#">L</a></li>
</ul>
</li>
<li><a href="#">سارافون</a>
<ul>
<li><a href="#">S</a></li>
<li><a href="#">M</a></li>
<li><a href="#">L</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#"><i class="fa fa-fw fa-dollar"></i> تخفیفات</a></li>
<li><a href="#"><i class="fa fa-fw fa-phone"></i> Contact</a></li>
</ul>
</div>
</body>
</html>