天天看點

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

demo:

http://jianwangsan.cn/toolbox

(二)全部工具裡面的按鈕和樣式

我将他拆成五部分:

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

第一部分是上面的大按鈕那一排;

第二部分是小按鈕;

第三部分是一條顔色很淡的線,他隻在app有多行的情況下,在行間有;

第四部分是标題;

第五部分是右邊的滾動條;

①為了友善子產品化開發,我先制作模闆,然後實際編寫代碼的時候,根據樣式已經設定好的模闆,來添加内容,這樣友善調試和制作

②大按鈕:

先分為整體和具體每個按鈕;

每個按鈕分為背景圖、遮罩層(下半部分的灰色陰影),文字title,文字說明,還有移動上去可能顯示的添加按鈕,共計五部分。

html:

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

div.contentbox  

    //下面這個是全部工具裡頁面最頂級的,目前共有兩個,通過displaynone這個類是否存在,來決定顯示哪個  

    div.toolbox-all  

        //這個是最上面的大圖示那一行  

        div.firstrow  

            //以下是單個按鈕  

            div.bigtool  

                //背景圖  

                span.img(style='background-image: url(../img/bigimg01.png)')  

                //陰影遮罩  

                span.mask  

                //文字  

                div.text  

                    div.title   微信清理  

                    div.description     定期清理微信,節省手機空間  

                //添加按鈕  

                div.addbutton   添 加  

                span.img(style='background-image: url(../img/bigimg02.png)')  

                    div.title   雷電os  

                    div.description     雷電os editor 舊機變新機  

                span.img(style='background-image: url(../img/bigimg03.png)')  

                    div.title   手機相冊擴容  

                    div.description     無損處理照片,騰出50%空間  

css

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

.back .contentbox > div {  

    width: 100%;  

    height: 100%;  

    box-sizing: border-box;  

}  

.back .contentbox .toolbox-all {  

    background: white;  

    padding: 30px;  

    overflow: auto;  

.back .contentbox .toolbox-my {  

    background: green;  

.back .contentbox .toolbox-all .firstrow {  

    height: 140px;  

    display: flex;  

    justify-content: space-between;  

.back .contentbox .toolbox-all .firstrow .bigtool {  

    width: 300px;  

    position: relative;  

    cursor: pointer;  

.back .contentbox .toolbox-all .firstrow .bigtool .img {  

    display: inline-block;  

    position: absolute;  

.back .contentbox .toolbox-all .firstrow .bigtool .mask {  

    background-image: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0.8) 100%);  

.back .contentbox .toolbox-all .firstrow .bigtool .text {  

    bottom: 0;  

    left: 0;  

    right: 0;  

    height: 55px;  

    padding: 0 10px;  

.back .contentbox .toolbox-all .firstrow .bigtool .text .title {  

    font-weight: 600;  

    font-size: 18px;  

    color: white;  

.back .contentbox .toolbox-all .firstrow .bigtool .text .description {  

    font-size: 14px;  

    margin-top: 10px;  

    color: rgb(218, 218, 218);  

.back .contentbox .toolbox-all .firstrow .bigtool .addbutton {  

    display: none;  

    bottom: 10px;  

    right: 12px;  

    width: 60px;  

    height: 22px;  

    background-image: linear-gradient(rgb(98, 227, 25) 0%, rgb(68, 208, 27) 100%);  

    font-size: 12px;  

    text-align: center;  

    line-height: 20px;  

    border: 1px solid rgb(65, 199, 36);  

    -webkit-border-radius: 1px;  

    -moz-border-radius: 1px;  

    border-radius: 1px;  

.back .contentbox .toolbox-all .firstrow .bigtool:hover .addbutton {  

    display: block;  

③小按鈕:

分為左邊的圖檔,右邊的文字(title和description),添加按鈕

所有小按鈕放在同一個commonrow類裡面,這個commonrow是彈性布局。

commonrow和上面的firstrow是平級的

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

div.commanrow  

    div.normaltool  

        div.img  

        div.text  

            div.title   手遊模拟器  

            div.description     電腦玩手遊,挂機輔助神器  

        div.addbutton   添 加  

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

.back .contentbox .commanrow {  

    flex-flow: wrap;  

.back .contentbox .commanrow .normaltool {  

    height: 70px;  

    padding: 5px;  

    -webkit-box-sizing: border-box;  

    -moz-box-sizing: border-box;  

.back .contentbox .commanrow .normaltool:hover {  

    outline: 1px solid #dadada;  

.back .contentbox .commanrow .normaltool .img {  

    height: 60px;  

    background-color: blue;  

.back .contentbox .commanrow .normaltool .text {  

    left: 75px;  

    right: 5px;  

    top: 5px;  

    bottom: 5px;  

.back .contentbox .commanrow .normaltool .text .title {  

    line-height: 35px;  

    font-size: 16px;  

.back .contentbox .commanrow .normaltool .text .description {  

    line-height: 25px;  

    color: #aaa;  

.back .contentbox .commanrow .normaltool .addbutton {  

    top: 10px;  

    right: 15px;  

.back .contentbox .commanrow .normaltool:hover .addbutton {  

④一條顔色很淡的線,分為兩種情況,頂層的,和間層的。

直接插入一個div,利用

border: 1px dotted rgb(209, 209, 209);

屬性來設定,

div.dotted

在頂層的時候,和firstrow平級,在間層的時候,和.normaltool平級

css:

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

.back .contentbox .dotted {  

    border: 1px dotted rgb(209, 209, 209);  

    margin-bottom: 10px;  

⑤标題:

兩部分,左邊的綠色豎線,右邊的文字,簡單暴力

html

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

div.titlerow  

    span.titlerow-left  

    span.titlerow-text  電腦安全  

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

.back .contentbox .titlerow {  

    height: 20px;  

    margin-top: 25px;  

.back .contentbox .titlerow .titlerow-left {  

    width: 2px;  

    background-color: rgb(42, 191, 29);  

.back .contentbox .titlerow .titlerow-text {  

    margin-left: 10px;  

    vertical-align: top;  

    color: #000;  

⑥滾動條

分為四部分:滾動條整體、滾動條背景、滾動條、兩端的按鈕

不需要html代碼;

css代碼限制為目前頁面生效:

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

/* 有這行才有效,滾動條的寬度 */  

.back .contentbox ::-webkit-scrollbar {  

    width: 12px;  

/* 滾動條的背景 */  

.back .contentbox ::-webkit-scrollbar-track {  

    background-color: rgb(242, 242, 242);  

/*滾動條*/  

.back .contentbox ::-webkit-scrollbar-thumb {  

    -webkit-border-radius: 5px;  

    border-radius: 5px;  

    background: rgb(218, 218, 218);  

.back .contentbox ::-webkit-scrollbar-button {  

總結:

目前情況是小按鈕沒有背景圖,暫時不做,隻起到占位效果,背景圖等做按鈕類時,再根據實際需要設定和添加。

後附目前為止的代碼:

html:(jade格式)

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

extends layout  

block content  

    link(rel='stylesheet', href='./stylesheets/toolboxes.css')  

    script(type="text/javascript",src='javascripts/toolboxes.js')  

    div 部落格位址:  

        a(href='http://blog.csdn.net/qq20004604?viewmode=list' target='_blank') http://blog.csdn.net/qq20004604?viewmode=list  

        br  

    div.back  

        div.tooltop  

            div.tooltop-img  

            div.tooltab  

                div.tool#alltool  

                    span.img.alltool.select  

                    span.text    全部工具  

                    div.hover  

                div.tool#mytool  

                    span.img.mytool  

                    span.text    我的工具  

        div.contentbox  

            //下面這個是全部工具裡頁面最頂級的,目前共有兩個,通過displaynone這個類是否存在,來決定顯示哪個  

            div.toolbox-all  

                //這個是最上面的大圖示那一行  

                div.firstrow  

                    //以下是單個按鈕  

                    div.bigtool  

                        //背景圖  

                        span.img(style='background-image: url(../img/bigimg01.png)')  

                        //陰影遮罩  

                        span.mask  

                        //文字  

                        div.text  

                            div.title   微信清理  

                            div.description     定期清理微信,節省手機空間  

                        //添加按鈕  

                        div.addbutton   添 加  

                        span.img(style='background-image: url(../img/bigimg02.png)')  

                            div.title   雷電os  

                            div.description     雷電os editor 舊機變新機  

                        span.img(style='background-image: url(../img/bigimg03.png)')  

                            div.title   手機相冊擴容  

                            div.description     無損處理照片,騰出50%空間  

                //橫線那一行,如果是多行app,應考慮使用另外一個  

                div.dotted  

                div.commanrow  

                    div.normaltool  

                        div.img  

                            div.title   手遊模拟器  

                            div.description     電腦玩手遊,挂機輔助神器  

                    div.dotted  

                div.titlerow  

                    span.titlerow-left  

                    span.titlerow-text  電腦安全  

            div.toolbox-my.displaynone  

css代碼:

前端的小玩意(9.2)——做一個仿360工具箱的web頁面(全部工具裡面的模闆)

a[href='/toolbox'] {  

    color: #555;  

    text-decoration: none;  

    background-color: #e5e5e5;  

    -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);  

    -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);  

    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);  

.back {  

    height: 600px;  

    -webkit-box-shadow: 0px 0px 2px #555;  

    -moz-box-shadow: 0px 0px 2px #555;  

    box-shadow: 0px 0px 2px #555;  

    min-width: 1000px;  

.back * {  

    border: 0;  

    padding: 0;  

    margin: 0;  

.back .tooltop {  

    height: 120px;  

    background-color: white;  

.back .tooltop-img {  

    background-image: url(../img/toolboxbackground.png);  

    background-size: cover;  

.back .tooltab {  

    height: 35px;  

.back .tooltab .tool {  

    margin-left: 20px;  

    width: 140px;  

    line-height: 30px;  

    font-size: 22px;  

    font-weight: 900;  

    cursor: default;  

    -webkit-user-select: none;  

    -moz-user-select: none;  

    -ms-user-select: none;  

    user-select: none;  

.back .tooltab .tool .img {  

    height: 27px;  

    width: 27px;  

    background-repeat: no-repeat;  

    vertical-align: middle;  

    background-image: url(../img/toolbox.png);  

.back .tooltab .tool .img.alltool {  

    background-position: 0 0;  

.back .tooltab .tool .img.alltool.select {  

    background-position: 0 -50px;  

.back .tooltab .tool .img.mytool {  

    background-position: -40px 0;  

.back .tooltab .tool .img.mytool.select {  

    background-position: -40px -50px;  

.back .tooltab .tool .text {  

.back .tooltab .hover {  

    height: 2px;  

    width: 125px;  

    bottom: -2px;  

.back .contentbox {  

    top: 120px;  

js代碼:

無新增,參照上一篇,略。

繼續閱讀