我正在创建一个下拉菜单,而不是在关闭LI标记后的另一个UL,而是使用DIV标记代替,因为我没有显示另一个无序列表,我&# 39; m显示登录信息。
以下是问题的图片,链接在悬停时被推翻。
如果有人知道解决方案,那将非常感谢!提前谢谢。
编号:S
.menu {
height: 60px;
width: 100%;
background-color: #fcfcfc;
padding: 1px;
}
.menu nav ul {
list-style: none;
list-style-type: none;
}
.menu nav ul li {
float: left;
}
.menu nav ul li a {
font-size: 18px;
color: #555;
text-decoration: none;
text-transform: uppercase;
padding: 21px 20px;
}
.menu nav ul li a:hover {
transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
-moz-transition: all .3s ease;
-webkit-transition: all .3s ease;
background-color: rgba(0, 0, 0, .3);
color: #333;
}
.menu nav ul li>.glob-auth {
width: 300px;
background-color: #fcfcfc;
display: none;
margin-top: 28px;
padding: 0;
border-radius: 20px;
-o-border-radius: 20px;
-ms-border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
z-index: 3;
}
.menu nav ul li>.glob-auth .glob-auth-top {
padding: 1px;
background-color: #00B16A;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.menu nav ul li>.glob-auth .glob-auth-top header h1 {
padding: 0;
margin: 0;
color: #fcfcfc;
padding-left: 10px;
}
.menu nav ul li>.glob-auth .glob-auth-body {
padding: 10px;
}
.menu nav ul li>.glob-auth .glob-auth-body input {
padding: 10px;
width: 260px;
border-style: none;
background-color: rgba(0, 0, 0, .1);
font-family: 'Open Sans', sans-serif;
font-size: 16px;
border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
.menu nav ul li>.glob-auth .glob-auth-body input:focus {
outline: none;
}
.menu nav ul li>.glob-auth .glob-auth-body input:nth-child(2) {
margin-top: 10px;
margin-bottom: 10px;
}
.menu nav ul li>.glob-auth .glob-auth-body button {
padding: 10px;
font-size: 18px;
background-color: #009157;
border-style: none;
width: 100%;
color: #fcfcfc;
font-family: 'Open Sans', sans-serif;
border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-bottom: 4px solid rgba(0, 0, 0, .3);
cursor: pointer;
}
.menu nav ul li>.glob-auth .glob-auth-body button:focus {
outline: none;
}
.menu nav ul li:hover>.glob-auth {
display: block;
}

<div class="menu">
<nav>
<ul>
<li><a href="#">Login</a>
<div class="glob-auth">
<div class="glob-auth-top">
<header>
<h1>Login</h1>
</header>
</div>
<div class="glob-auth-body">
<form method="post">
<input type="text" name="l_user" placeholder="Enter username" autocomplete="off" maxlength="20">
<input type="password" name="l_pass" placeholder="Enter password" autocomplete="off" maxlength="120">
<button name="l_submit">Login</button>
</form>
</div>
</div>
</li>
<li><a href="#">Register</a>
<div class="glob-auth">
<div class="glob-auth-top">
<header>
<h1>Register</h1>
</header>
</div>
<div class="glob-auth-body">
<form method="post">
<input type="text" name="l_user" placeholder="Enter username" autocomplete="off" maxlength="20">
<input type="password" name="l_pass" placeholder="Enter password" autocomplete="off" maxlength="120">
<button name="l_submit">Login</button>
</form>
</div>
</div>
</li>
</ul>
</nav>
</div>
&#13;
答案 0 :(得分:1)
插入此内容:
.menu nav ul li > .glob-auth {
position: absolute;
//Other codes...
}
.menu{
height: 60px;
width: 100%;
background-color: #fcfcfc;
padding: 1px;
}
.menu nav ul{
list-style: none;
list-style-type: none;
}
.menu nav ul li{
float: left;
}
.menu nav ul li a{
font-size: 18px;
color: #555;
text-decoration: none;
text-transform: uppercase;
padding: 21px 20px;
}
.menu nav ul li a:hover{
transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
-moz-transition: all .3s ease;
-webkit-transition: all .3s ease;
background-color: rgba(0,0,0,.3);
color: #333;
}
.menu nav ul li > .glob-auth {
width: 300px;
background-color: #fcfcfc;
display: none;
margin-top: 28px;
padding: 0;
border-radius: 20px;
-o-border-radius: 20px;
-ms-border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
z-index: 3;
position: absolute;
}
.menu nav ul li > .glob-auth .glob-auth-top{
padding: 1px;
background-color: #00B16A;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.menu nav ul li > .glob-auth .glob-auth-top header h1{
padding: 0;
margin: 0;
color: #fcfcfc;
padding-left: 10px;
}
.menu nav ul li > .glob-auth .glob-auth-body{
padding: 10px;
}
.menu nav ul li > .glob-auth .glob-auth-body input{
padding: 10px;
width: 260px;
border-style: none;
background-color: rgba(0,0,0,.1);
font-family: 'Open Sans', sans-serif;
font-size: 16px;
border-radius: 3px;
-o-border-radius: 3px;
-ms-border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
.menu nav ul li > .glob-auth .glob-auth-body input:focus{
outline: none;
}
.menu nav ul li > .glob-auth .glob-auth-body input:nth-child(2){
margin-top: 10px;
margin-bottom: 10px;
}
.menu nav ul li > .glob-auth .glob-auth-body button{
padding: 10px;
font-size: 18px;
background-color: #009157;
border-style: none;
width: 100%;
color: #fcfcfc;
font-family: 'Open Sans', sans-serif;
border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-bottom: 4px solid rgba(0,0,0,.3);
cursor: pointer;
}
.menu nav ul li > .glob-auth .glob-auth-body button:focus{
outline: none;
}
.menu nav ul li:hover > .glob-auth{
display: block;
}
&#13;
<div class="menu">
<nav>
<ul>
<li><a href="#">Login</a>
<div class="glob-auth">
<div class="glob-auth-top">
<header>
<h1>Login</h1>
</header>
</div>
<div class="glob-auth-body">
<form method="post">
<input type="text" name="l_user" placeholder="Enter username" autocomplete="off" maxlength="20">
<input type="password" name="l_pass" placeholder="Enter password" autocomplete="off" maxlength="120">
<button name="l_submit">Login</button>
</form>
</div>
</div>
</li>
<li><a href="#">Register</a>
<div class="glob-auth">
<div class="glob-auth-top">
<header>
<h1>Register</h1>
</header>
</div>
<div class="glob-auth-body">
<form method="post">
<input type="text" name="l_user" placeholder="Enter username" autocomplete="off" maxlength="20">
<input type="password" name="l_pass" placeholder="Enter password" autocomplete="off" maxlength="120">
<button name="l_submit">Login</button>
</form>
</div>
</div>
</li>
</ul>
</nav>
&#13;