我正在为客户建立一个网站,但我无法让下拉菜单在导航栏下方显示清晰 - 而是与导航栏重叠,如果我增加了上边距下拉菜单将其推送到导航栏下方,下拉列表与父列表项之间存在间隙,使其显示的悬停属性不会生效。
我在这里创建了一个导航栏的小提琴 - http://jsfiddle.net/s4dpby4v/1/
您可以在此处查看实时版本 - http://japesfawcett.com/ps/index.html
HTML:
<div class="header">
<div class="logo">
<h1><a href="index.html">PAM SHAW INTERIORS</a></h1>
</div>
<nav>
<ul>
<li><a href="about.html">ABOUT</a></li>
<li class="has-drop">
<a href="#">WORK +</a>
<ul class="drop-down">
<li style="padding-bottom: 0;"><a href="#">COMMERCIAL</a></li>
<li style="padding-right: 80px; padding-bottom: 0;"><a href="#">RESIDENTIAL</a></li>
</ul>
</li>
<li><a href="portfolio.html">CONTACT</a></li>
</ul>
</nav>
</div>
CSS:
.header {
width: 100%;
background-color: #fff;
margin: 0 auto;
height: 75px;
z-index: 9999;
}
.logo h1 {
float: left;
font-size: 20px;
letter-spacing: 4px;
width: 25%;
padding-top: 10px;
margin-top: 18px;
margin-left: 75px;
font-weight: 300;
}
.logo a {
text-decoration: none;
color: #000;
}
nav {
font-family: 'Lato', sans-serif;
width: 60%;
font-size: 14px;
font-weight: 300;
text-align: right;
letter-spacing: 4px;
float: right;
margin-top: 19px;
margin-right: 75px;
}
nav ul {
float: right;
list-style: none;
padding-top: -5px;
}
nav li {
padding-left: 15px;
padding-right: 10px;
padding-bottom: 15px;
display: inline-block;
}
nav ul li ul.drop-down {
width: 100%;
background: #fff;
display: none;
position: absolute;
z-index: 999;
padding: 5px 0 5px 0;
margin: 15px 0 0 0;
left: 0;
line-height: 2.5;
clear: both;
border-top: 1px solid #F1F1F1;
}
nav li:hover ul.drop-down {
display: block;
}
nav ul li ul.dropdown li {
display: block;
padding: 0;
margin: 0;
}
nav li a {
text-decoration: none;
color: #000;
display: inline-block;
}
nav li a:hover {
text-decoration: none;
color: #CCC;
-webkit-transition: all 800ms ease;
-moz-transition: all 800ms ease;
-ms-transition: all 800ms ease;
-o-transition: all 800ms ease;
transition: all 800ms ease;
}
非常感谢任何指导或帮助!
答案 0 :(得分:1)
您可以查看此css
.has-drop {
padding-bottom: 30px;
}
nav ul li ul.drop-down
{
margin: 27px 0 0;
}
答案 1 :(得分:1)
myMap
将清理你的下拉,你只需要删除你在这里的内联样式来修复列表样式:
.has-drop {position: relative;}
nav ul li ul.drop-down {width: auto;}
nav li li {width: 100%; text-align: center; box-sizing: border-box;}
这是我的小提琴:http://jsfiddle.net/s4dpby4v/6/