最近自己需要一套后台管理的模版,然后去網上查找,模版的確很多,但是適合我的並不多。我需要的模版是不會很大,我能夠控制代碼,樣式不要太古朴,最好有點CSS3的效果。最后終於找到一張主頁,然后再根據這個主頁來編輯其他的后台部分。第一眼看到這個樣式,就非常滿意。現在只做了四張頁面,登錄、首頁、菜單管理和菜單添加頁面。
瀏覽器兼容是盡量做到IE8以上可以使用,firefox、chrome瀏覽器等能完全兼容。由於IE8無法解析CSS3,所以有些地方會額外的制作CSS。下面的代碼都不是完整的代碼,完整代碼可以參考下載的demo。
一、頁面大量使用了HTML5與CSS3
自己對於html5的理解一直很膚淺,缺少想象力,這次通過這個模版頁面可以更多的了解到這些標簽在什么場合下比較適合用。很多地方也用到了選擇器,拓寬了自己的眼見。左邊欄的小圖標原先是用img展示的,現在都被我換成了icon字體了,直接通過icomoon網站在線獲取,使用icon字體將很容易控制樣式以及大小。
<header id="header"> <hgroup> <h1 class="site_title"><a href="index.html">Website Admin</a></h1> <h2 class="section_title">Dashboard</h2><div class="btn_view_site"><a href="http://www.cnblogs.com/strick/">View Site</a></div> </hgroup> </header>
.quick_search input[type=text] { -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px; border: 1px solid #bbb; height: 26px; width: 90%; color: #ccc; -webkit-box-shadow: inset 0 2px 2px #ccc, 0 1px 0 #fff; -moz-box-shadow: inset 0 2px 2px #ccc, 0 1px 0 #fff; box-shadow: inset 0 2px 2px #ccc, 0 1px 0 #fff; text-indent: 30px; background: #fff url(../images/icn_search.png) no-repeat; background-position: 10px 6px; }
二、寬度使用%比,復用更方便
這套模版全部是用%設置寬度,這次我也感受到了這種設置方式的便捷。模版只提供了首頁,登錄頁面是后面自己加的。這個部分就是自己在最外層定義了一個寬度,里面的根據百分比顯示,完全沒有走樣,也不用修改代碼。
<div class="w500 mc ovh"> <section id="main" > <article class="module width_full"> <header><h3>登錄</h3></header> </article> </section> </div>
只是簡單的加了個<div class="w500 mc ovh">就完成了一個頁面布局。
三、通用美觀的提示
這個提示直接復制就可以,代碼很簡潔,樣式看着就是很舒服。
<h4 class="alert_info">Welcome to the free MediaLoot admin panel template, this could be an informative message.</h4> <h4 class="alert_warning">A Warning Alert</h4> <h4 class="alert_error">An Error Message</h4> <h4 class="alert_success">A Success Message</h4>
四、通用table樣式
后來展示列表信息,用table比較方便,寬度也是用%比展示,復制到各個頁面能夠很和諧的融入進去。用icon來展示操作,也很清晰。
五、CSS3按鈕
一直就想試試用CSS3來制作按鈕特效了,這次終於有機會啦,在網上找了一套,自己做了些細微修改,並做了瀏覽器的兼容。
效果的確不錯,但是CSS的代碼一下子就增加了好多,而且為了能讓IE8這些不兼容CSS3的瀏覽器能達到差不多的效果,還額外寫了點CSS,通過JS插件modernizr輔助。
a.button { display:inline-block; position: relative; height: 25px; width: 80px; margin: 0 10px 18px 0; text-decoration: none; font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: bold; line-height: 25px; text-align: center; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } a.button:before, a.button:after { content: ''; position: absolute; left: -1px; height: 25px; width: 80px; bottom: -1px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } a.button:before { height: 23px; bottom: -4px; border-top: 0; -webkit-border-radius: 0 0 3px 3px; -moz-border-radius: 0 0 3px 3px; border-radius: 0 0 3px 3px; -webkit-box-shadow: 0 1px 1px 0px #bfbfbf; -moz-box-shadow: 0 1px 1px 0px #bfbfbf; box-shadow: 0 1px 1px 0px #bfbfbf; } /* MODERNIZR FALLBACK */ .no-cssgradients a.button, .no-cssgradients a.button:visited, .no-borderradius a.button, .no-borderradius a.button:visited, .no-generatedcontent a.button, .no-generatedcontent a.button:visited { background: url(../images/img_btn.png) no-repeat 0 0px; height: 32px; width: 82px; }
六、CSS3分頁
這個也是后面自己添加上去的,挺融入這個風格中的,在里面也加了些CSS3的元素
ul.paginationA01 li a { color:#474747; border:solid 1px #B6B6B6; padding:6px 9px 6px 9px; background:#E6E6E6; background:-moz-linear-gradient(top,#FFFFFF 1px,#F3F3F3 1px,#E6E6E6); background:-webkit-gradient(linear,0 0,0 100%,color-stop(0.02,#FFFFFF),color-stop(0.02,#F3F3F3),color-stop(1,#E6E6E6)); } ul.paginationA01 li a:hover, ul.paginationA01 li a.current { background:#FFFFFF; } ul.paginationA01 li a:active{ background:#D9D9D9; background:-moz-linear-gradient(top,#FFFFFF 1px,#EAEAEA 1px,#b6b6b6); background:-webkit-gradient(linear,0 0,0 100%,color-stop(0.02,#FFFFFF),color-stop(0.02,#EAEAEA),color-stop(1,#b6b6b6)); }
七、單元測試的模塊
在tests文件夾下面,我已經添加好單元測試的模塊,能夠讓自己以后的JS腳本代碼更加的健壯。
通過上面的幾個分解模塊,基本上可以滿足后台管理各個部分的樣式需求,自己也可以有一套能修改的管理模版啦!
demo下載:
http://download.csdn.net/download/loneleaf1/7711311
參考資料:
http://medialoot.com/preview/admin-template/index.html 網頁后台模版
http://webdesign.tutsplus.com/tutorials/orman-clarks-chunky-3d-web-buttons-the-css3-version--webdesign-5731 按鈕制作
http://icomoon.io/ 自己制作icon