藍色專業風格,帶當前位置指示標記的導航欄,結構清晰、代碼規範。
.clearfix + :after + zoom:1 兼容 IE6/7li 右側背景 + a 左側背景組合自適應寬度.current 標記當前頁,:hover 懸停態,疊加背景圖實現視覺差異<em> 絕對定位於 li 內,top: -20px 懸浮顯示.menu_nav {
width: 970px; height: 48px;
background: url(images/nav_bg.gif) repeat-x;
margin-top: 18px; float: left;
}
.menu_nav .nav_content {
padding-left: 25px;
background: url(images/nav_l_bg.gif) no-repeat;
float: left;
}
.menu_nav .nav_content li {
width: 88px; height: 48px;
padding: 0 13px 0 15px;
background: url(images/nav_li_right.gif) no-repeat right center;
float: left; line-height: 48px; text-align: center;
font: bold 14px/48px "微軟雅黑";
}
.menu_nav .nav_content li a {
display: block; width: 88px; height: 48px; color: #fff;
}
.menu_nav .nav_content li.current { line-height: 37px; }
.menu_nav .nav_content li em {
position: absolute; top: -20px; left: 40px;
width: 35px; height: 21px;
background: url(images/bid_new.gif) no-repeat;
}
.menu_nav .nav_content li.current a,
.menu_nav .nav_content li a:hover {
width: 88px; height: 37px; line-height: 37px;
background: url(images/nav_li_current.gif) no-repeat;
color: #fff; text-decoration: none;
}
.menu_nav .nav_content li a:hover {
background: url(images/nav_li_hover.gif) no-repeat;
}
<div class="menu_navcc">
<div class="menu_nav clearfix">
<ul class="nav_content">
<li class="current"><a href="#"><span>網站首頁</span></a></li>
<li><a href="#"><span>廣告代碼</span></a></li>
<li><a href="#"><span>CSS教程</span></a></li>
<li style="position:relative;">
<a href="#"><span>導航菜單</span></a>
<em></em>
</li>
<li><a href="#"><span>源碼素材</span></a></li>
<li><a href="#"><span>常用代碼</span></a></li>
</ul>
<div class="menu_nav_right"></div>
</div>
</div>
nav、ul、li、a 語義化標籤flexbox 替代 float 佈局currentColor / CSS 變量統一色值管理