页面布局之--Font Awesome+导航
Font Awesome为您提供可缩放的矢量图标,您可以使用CSS所提供的所有特性对它们进行更改,包括:大小、颜色、阴影或者其它任何支持的效果。
下载地址:http://fontawesome.io/
1.引用方式:
<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/
<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>