Font Awesome爲您提供可縮放的矢量圖標,您可使用CSS所提供的全部特性對它們進行更改,包括:大小、顏色、陰影或者其它任何支持的效果。 下載地址:http://fontawesome.io/
1.引用方式:css
<head> <meta charset="UTF-8"> <title>Title</title> // 引用當前目錄下的 font-awesome.min.css <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css"> </head>
2.使用圖標:
圖標樣式:http://fontawesome.io/icons/html
<div class="right icons"> <!--將提供的樣式直接放到須要的位置--> <i class="fa fa-cc-visa" aria-hidden="true"></i> <a>..</a> </div> <div class="right icons"> <i class="fa fa-envelope-square" aria-hidden="true"></i> <a>3</a> </div>
3.佈局加導航欄展現:佈局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css"> <style> body{ margin: 0; } .left{ float: left; } .right{ float: right; } .pg-header{ height: 48px; background-color: #2459a2; color: #f5f5f5; min-width: 1180px; line-height: 48px; } .pg-header .logo{ width: 200px; background-color: #000795; text-align: center; } .pg-header .icons{ font-size: 30px; padding: 0 20px; } .pg-header .icons:hover{ background-color: #204982; } .pg-header .icons a{ font-size: 11px; display: inline-block; /*line-height: 1px; 能夠將不跟隨父級的line-height值 */ line-height: 1px; background-color: red; padding: 6px 3px; border-radius: 50%; } .pg-header .user{ margin-right: 80px; padding: 0 20px; height: 48px; position: relative; } .pg-header .user:hover .userinfo{ display: block; } .pg-header .user .userinfo{ z-index: 20; position: absolute; top: 48px; right: 0; width: 160px; background-color: #cccccc; color: black; display: none; } .pg-header .user .userinfo a{ display: block; } .pg-header .user:hover{ background-color: #204982; } .pg-header .user .headimg img{ width: 40px; height: 40px; margin-top: 4px; border-radius: 50% } </style> </head> <body> <div class="pg-header"> <div class="logo left"> 叨客廚子 </div> <div class="user right"> <a class="headimg" href="#"> <img src="tt.jpg" alt=""> </a> <div class="userinfo"> <a href="">我的信息</a> <a href="">通知</a> <a href="">關注</a> <a href="">註銷</a> </div> </div> <div class="right icons"> <i class="fa fa-cc-visa" aria-hidden="true"></i> <a>..</a> </div> <div class="right icons"> <i class="fa fa-envelope-square" aria-hidden="true"></i> <a>3</a> </div> </div> <div class="pg-footer"></div> </body> </html>