效果
1.HTML:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <link type="text/css" rel="stylesheet" href="css/style.css"> </head> <body> <div id="header"> <div class="navbar"> <img class="navbar-left" src="assets/images/navbar_logo.png"> <ul class="narbar-right"> <li> <a class="active" href="">Home</a> </li> <li> <a class="" href="">product</a> </li> <li> <a class="" href="">About</a> </li> <li> <a class="" href="">JoinUs</a> </li> <li> <a class="" href="">Contact</a> </li> </ul> </div> </div> </body> </html>
2.CSS
body{ background-color: #f9f9f9; margin: 0; padding: 0; } #header{ background-color: #ffffff; width: 100%; height: 52px; border-bottom: 1px solid #e9e9e9; position: fixed; top: 0; left: 0; } .navbar{ margin: 4px 20px; display: block; } .navbar-left{ float: left; width: 44px; } .narbar-right{ float: right; } .navbar li{ list-style-type: none; margin-left: 20px; display: inline-block; } .navbar li .active{ color: #ff7d0a; } .navbar a{ font-size: 16px; font-weight: 800; color: #636363; text-decoration: none; } .navbar a:hover{ color: #ee7204; }
原文:http://www.cnblogs.com/xinjiebi/p/5065186.html