项目实战 - Head制作
代码:
知识点
1、border-radius: 50%画圆
2、overflow: hidden 超出显示部分隐藏掉
3、overflow: scroll 超出显示部分出现滚动条
4、font awesone 插件实现小图标
5、z-index: 实现分层显示
6、position: relative absolute
7、min-width
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CRM</title> <link rel="stylesheet" href="static/css/font-awesome-4.6.3/css/font-awesome.css" /> <style type="text/css"> body{ margin: 0; } .left{ float: left; } .right{ float: right; } .pg-head{ background-color: cornflowerblue; height: 58px; line-height: 58px; min-width: 1080px; } .pg-head .logo{ width: 200px; font-size: 20px; font-family: "Microsoft YaHei UI"; color: white; text-align: center; } .pg-head .user-profile a.item{ padding: 0 20px; /*margin: 20px;*/ display: inline-block; } .pg-head .user-profile a.item:hover{ background-color: darkcyan; } .pg-head .avatar{ height: 40px; width: 40px; padding: 4px 10px; margin-right: 20px; /*margin: 4px 20px;*/ } .pg-head .avatar img{ width: 100%; height: 100%; border-radius: 50%; /*padding: 4px;*/ } .pg-head .avatar .user-menu{ display: none; width: 100px; border: 1px solid red; background-color: cornflowerblue; top: 48px; right: -3px; position: absolute; z-index: 100; } .pg-head .avatar .user-menu a{ display: block; line-height: 30px; } .pg-head .avatar:hover .user-menu{ display: block; } .pg-body{ min-width: 1080px; } .pg-body .menus{ position: absolute; top: 58px; left: 0; bottom: 0; width: 200px; background-color: cadetblue; } .pg-body .content{ position: absolute; top: 58px; bottom: 0; right: 0; left: 200px; z-index: 99; background-color: #dddddd; overflow: scroll; min-width: 880px; } </style> </head> <body> <div class="pg-head"> <div class="logo left">Openstack运维平台</div> <div class="avatar right" style="position: relative"> <a style="overflow: hidden"><img src="static/img/avatar.jpg"></a> <div class="user-menu"> <a>个人资料</a> <a>注销登录</a> </div> </div> <div class="user-profile right"> <a class="item"><i class="fa fa-language" aria-hidden="true"></i></a> <a class="item"><i class="fa fa-battery-three-quarters" aria-hidden="true"></i></a> <a class="item">注册</a> <a class="item">登录</a> </div> </div> <div class="pg-body"> <div class="menus"></div> <div class="content"> <p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p> <p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p> <p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p> <p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p> <p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p> <p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p><p>d</p> </div> </div> </body> </html>
效果图: