一、製作頂部區域 提示一個快捷鍵:(1)ctrl+/ /*.top .top_login>li{*/ /*list-style: none;*/ /*float:right;*/ /*}*/ (2)ctrl+shift+/ /*.top .top_login>li{ list-style: none ...
一、製作頂部區域
提示一個快捷鍵:(1)ctrl+/
/*.top .top_login>li{*/
/*list-style: none;*/
/*float:right;*/
/*}*/
(2)ctrl+shift+/
/*.top .top_login>li{
list-style: none;
float:right;
}*/
這兩種註釋的快捷鍵,一個每行都註釋,一個整體註釋。
二、開始設計努比亞界面的頭部信息
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="CSS/base.css"> <link rel="stylesheet" href="CSS/index.css"> </head> <body> <!--頂部區域--> <div class="top"> <div class="top_in"> <div class="top_left"> <h1><a href="#" title="努比亞"></a></h1><!--a標簽裡面的title屬性,就是用於當滑鼠放到a標簽上面的時候會顯示的文字--> </div> <div class="top_right"> <ul class="top_nav"> <li><a href="#">首頁</a></li> <li><a href="#">商城</a></li> <li><a href="#">產品</a></li> <li><a href="#">應用</a></li> <li><a href="#">服務</a></li> <li><a href="#">體驗店</a></li> <li><a href="#">社區</a></li> </ul> <ul class="top_login"> <!--這裡有一個註意點,我們想要使用的右浮動,所以三個li標簽應該倒敘寫,因為先寫的先浮動哦--> <li><a href="#">註冊</a></li> <li><a href="#">登錄</a></li> <li><a href="#"></a></li> </ul> </div> </div> </div> <!--廣告區域--> <div class="banner"></div> <!--內容區域--> <div class="content"></div> <!--底部區域--> <div class="footer"></div> </body> </html>
/*頂部區域*/ .top{ height:60px; width:100%;/*也就是和父元素一樣寬,這裡使用百分比的形式,使得網頁擴大減小都不會變形*/ background-color: black; } .top .top_in{ width: 1200px; margin:0 auto; height:100%; /*background-color: yellow;*/ } .top .top_left{ float:left; height:100%; width:190px; /*background-color: pink;*/ } .top .top_left>h1{ width: 100%; height: 100%; } .top .top_left>h1>a{ display: inline-block; width: 100%; height: 100%; background:url("../image/nubia_logo.png"); background-size: 190px 60px;/*設置圖片大小正好適配div塊的大小*/ } .top .top_right{ float:right; height: 100%; width: 800px; /*background-color: pink;*/ } .top .top_nav{ float:left; width:550px; height: 100%; /*background-color: skyblue;*/ } .top .top_nav>li{ float:left; list-style: none; } .top .top_nav>li>a{ font-size:25px; font-weight: bold;/*給文字加粗*/ line-height:60px; color:white;/*文字的顏色,直接是color*/ margin-left:20px;/*這是給文字添加空隙*/ text-decoration:none;/*去掉文字的下劃線*/ } /*.top .top_nav>li>a:hover{!*移動滑鼠上去變化顏色*!*/ /*color:#e82c07;*/ /*}*/ .top .top_login{ float:right; width: 150px; height: 100%; /*background-color: skyblue;*/ } .top .top_login>li{ list-style: none; float:right; margin-right:10px; } .top .top_login>li>a{ font-size:20px; font-weight:bold; line-height:60px; color:white; text-decoration:none; } .top ul>li>a:hover{/*移動滑鼠上去變化顏色*/ color:#e82c07; /*這裡我們使用.top ,top_login>li>a:hover而使用了ul來替代top_login這個可以說是代碼的重構,我們希望 li標簽里的文字滑鼠懸浮都變色,這樣我們把父層級一改,可以省略代碼,在後續編程中這些都是隱形的小技巧 */ } .top .top_login>li:nth-child(3){ width: 30px; height: 37px; background:url("../image/nubia_person.png"); margin-top:10px; } /*廣告區域*/ .banner{ height: 800px; width: 100%; background-color: green; } /*內容區域*/ .content{ height: 1883px; width: 100%; background-color: blue; } /*底部區域*/ .footer{ }
三、源碼:
D194_CSSWritingFormat.html
項目:Nubia
地址:
https://github.com/ruigege66/HTML_learning/blob/master/D194_CSSWritingFormat.html
https://github.com/ruigege66/HTML_learning/tree/master/Nubia
2.CSDN:https://blog.csdn.net/weixin_44630050
3.博客園:https://www.cnblogs.com/ruigege0000/
4.歡迎關註微信公眾號:傅里葉變換,個人賬號,僅用於技術交流,後臺回覆“禮包”獲取Java大數據學習視頻禮包