我建议在您的 html 中使用 div <div class="sepLine"></div> 并带有以下 css:
.sepLine{
height: 15px;
position: relative;
width: 100%;
top: 50px;
}
同时从这个类中移除 line-height 并添加高度:
.menu a
{
font: 500 15px Open Sans;
display: block;
color: white;
height: 50px; /*Change line-height with height*/
color: #FFF;
width: 140px;
text-align: center;
display: inline-block;
}
最后添加行高:
.menu > li > ul > li > a{
line-height: 50px; /*Add line height*/
}
fiddle
完整代码:
html
<div class="navigation">
<div class="sepLine"></div>
<ul class="menu">
<li><a href="#">Worker</a></li>
<li><a href="#" class="sub">Categories</a>
<ul>
<li><a href="#">Webdesign</a></li>
<li><a href="#">Inspiration</a></li>
<li><a href="#">Tutorials</a></li>
<li><a href="#">Development</a></li>
</ul>
</li>
<li><a href="#">Shop</a></li>
<li><a href="#">Account</a></li>
</ul>
</div>
css
/* RESET */
html, body, div, span, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video
{
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
body
{
line-height:1;
-webkit-font-smoothing: subpixel-antialiased;
}
article,aside,details,figcaption,figure, footer,header,hgroup,menu,nav,section
{
display:block;
}
blockquote, q
{
quotes:none;
}
blockquote:before, blockquote:after, q:before, q:after
{
content:"";
content:none;
}
a
{
margin:0;
padding:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
text-decoration: none;
}
ul
{
list-style: none;
}
::-webkit-input-placeholder
{
color: #fff;
}
:-moz-placeholder
{
color: #fff;
opacity: 1;
}
::-moz-placeholder
{
color: #fff;
opacity: 1;
}
:-ms-input-placeholder
{
color: #fff;
}
/* BOX */
*, *:before, *:after
{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* CLEARFIX */
.clearfix:before, .clearfix:after
{
content: "";
display: table;
}
.clearfix:after
{
clear: both;
}
.clearfix
{
*zoom: 1;
}
/* NAVIGATION */
.navigation
{
width: 100%;
height: 50px;
background: #34495E;
position: fixed;
top: 0;
}
.menu
{
width: 960px;
height: 50px;
margin: 0px auto;
padding: 0px;
}
.menu > li
{
float: left;
position: relative;
}
.menu ul
{
display: none;
position: absolute;
left: 0;
top: 100%;
}
.menu a
{
font: 500 15px Open Sans;
display: block;
color: white;
height: 50px; /*Change line-height with height*/
color: #FFF;
width: 140px;
text-align: center;
display: inline-block;
}
.menu a:hover, .menu a:active
{
color: #1ABC9C;
}
.menu li
{
list-style: none;
}
.menu li:last-child
{
float: right;
}
.menu li:hover ul
{
display: block;
background: #34536e;
}
.navigation
{
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
.account
{
float: right;
}
.sepLine{
height: 15px;
position: relative;
width: 100%;
top: 50px;
}
.menu > li > ul > li > a{
line-height: 50px; /*Add line height*/
}