如何消除导航和标题之间的差距?导航和主要内容之间? 导航按钮即ul处于完美的位置。但黑色导航栏给我带来了许多不必要的麻烦!我无法解决它!
这是我的HTML
<div id="header">
<div id="header-container">
Logo goes here!!
</div>
</div>
<div class="nav">
<div class="nav-container">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Browse</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</div>
</div>
<div class="main-body">
<h1>Contant here!</h1>
</div>
这是我的css代码:
{
margin: 0;
padding: 0;
}
.clear{
clear: both;
}
body{
margin: 0 auto;
background: #cccccc;
}
#header{
background: #FF9900;
height: 160px;
width: 100%;
}
#header-container{
width: 960px;
height: 160px;
margin: 0px auto 0px auto;
}
.nav{
width: 100%;
height: 70px;
background: #000000;
margin-top: 0px;
margin-bottom: 0px;
}
.nav .nav-container{
width: 960px;
height: 62px;
margin: auto;
margin-top: 5px;
}
.nav .nav-container ul{
margin-top: 0px;
padding-top: 0px;
margin-left: auto;
margin-right: auto;
margin-bottom: 0px;
}
.nav .nav-container ul li{
display: inline-block;
padding: 0px;
border-radius: 10px;
margin-right: 20px;
margin-left: 7px;
background: #000000;
}
.nav .nav-container ul li a{
color: #FF9900;
text-decoration: none;
font-weight: bold;
font-size: 22px;
display: inline-block;
width:150px;
text-align: center;
height: 58px;
line-height: 250%;
}
.nav .nav-container ul li a:hover{
background:#FF9900;
color: white;
border-radius: 10px;
}
.main-body{
width: 960px;
background: white;
margin:auto;
margin-top: 0px;
}
答案 0 :(得分:0)
将margin-top: 5px;
更改为margin-top: 0;
中的.nav .nav-container
。
.nav .nav-container{
width: 960px;
height: 62px;
margin: auto;
/* margin-top: 5px; becomes */ margin-top: 0;
}