管理页面布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>后台管理</title> <style> .pg-header{ height: 48px; background-color: #2459a2; color: white; } .pg-content .menu{ position: fixed; top: 48px; left: 0; bottom: 0; width: 200px; background-color: #dddddd; } .pg-content .content{ position: fixed; top: 48px; right: 0; bottom: 0; left: 200px; background-color: purple; overflow: auto; } .left{ float: left; } .right{ float: right; } </style> </head> <body style="margin: 0 auto;"> <div class="pg-header"></div> <div class="pg-content"> <div class="menu left"></div> <div class="content left"> </div> </div> <div class="pg-footer"></div> </body> </html>
效果图:
这种布局的好处是当content内容超出浏览器高度时,会出现滚动条的效果。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>后台管理</title> <style> .pg-header{ height: 48px; background-color: #2459a2; color: white; line-height: 48px; } .pg-header .logo{ width: 200px; background-color: blueviolet; text-align: center; } .pg-header .user{ height: 48px; margin-right: 60px; padding: 0 20px; } .pg-header .user .a img{ width: 40px; height: 40px; margin-top: 4px; border-radius: 50%; } .pg-header .user .b{ z-index: 20; position: absolute; top: 48px; right: -43px; background-color: #666666; width: 160px; display: block; } .pg-header .user .b a{ color: white; display: block; } .pg-header .user:hover{ background-color: #204982; } .pg-content .menu{ position: absolute; top: 48px; left: 0; bottom: 0; width: 200px; background: #dddddd; } .pg-content .content{ position: absolute; top: 48px; right: 0; bottom: 0; left: 200px; background-color: purple; min-width: 980px; z-index: 10; overflow: auto; } .left{ float: left; } .right{ float: right; } .pg-header .user:hover .b{ display:block; } </style> </head> <body style="margin: 0 auto;"> <div class="pg-header"> <div class="logo left"> 后台管理 </div> <div id='i1' class="user right" style="position: relative;"> <a class='a' href="#"> <img class='img' src="girl.jpg"/> </a> <div class="b"> <a>我的资料</a> <a>注销</a> </div> </div> </div> <div class="pg-content"> <div class="menu left"></div> <div class="content left"> </div> </div> <div class="pg-footer"></div> </body> </html>
图标网站:fontawesome.com
使用教程:http://www.runoob.com/font-awesome/fontawesome-tutorial.html