サマリー:<!DOCTYPE html><html lang="zh_cn"><head> <meta charset="UTF-8"><!-- <link rel="stylesheet" href="static/css/s
<!DOCTYPE html>
<html lang="zh_cn">
<head>
<meta charset="UTF-8">
<!-- <link rel="stylesheet" href="static/css/style1.css">-->
<link rel="stylesheet" href="static/css/font-awesome-4.7.0/css/font-awesome.css">
<title>Title</title>
<style>
/*給所有標(biāo)簽定義*/
* {
margin: 0;
padding: 0;
}
/*給a標(biāo)簽定義一個(gè)固定樣式*/
a {
text-decoration-line: none;
color: #C3C3C3;
font-size: 13px;
}
.clear {
clear: both;
}
/*導(dǎo)航欄設(shè)置背景顏色和高度*/
.header {
background-color: #F5F5F5;
height: 40px;
width: 100%;
}
/*導(dǎo)航欄內(nèi)容框的寬高設(shè)置*/
.header_content {
width: 1200px;
line-height: 40px;
margin: 0 auto;
background-color: #F5F5F5;
}
/*設(shè)置左邊導(dǎo)航欄的高度,并進(jìn)行向左浮動(dòng)*/
.header_left {
height: 40px;
float: left;
}
/*設(shè)置左邊導(dǎo)航欄按鈕間的間距*/
.header_left a {
margin-right: 3px;
}
/*設(shè)置右邊導(dǎo)航欄的高度,并進(jìn)行向右浮動(dòng)*/
.header_right {
height: 40px;
float: right;
}
/*設(shè)置右邊導(dǎo)航欄按鈕間的間距*/
.header_right a {
margin-left: 3px;
}
/*將.header_a類(lèi)選擇器中元素該為行內(nèi)塊元素,并設(shè)置文本居中顯示*/
.header_a{
display: inline-block;
height: 40px;
width: 80px;
text-align: center;
position: relative;
}
/*添加光標(biāo)停留時(shí).header_a類(lèi)標(biāo)簽的顯示效果*/
.header_a:hover {
/*line-height: 40px;*/
background-color: white;
}
/*添加光標(biāo)停留時(shí)<a>的顯示效果*/
a:hover {
color: #FF5000;
}
/*設(shè)置無(wú)序列表的隱藏和border*/
.header_right_a {
border:1px solid #F5F5F5;
border-top: none;
display: none;
}
/*取消無(wú)序列表的小點(diǎn),設(shè)置列表內(nèi)容的高度和文字向左對(duì)齊*/
li {
list-style: none;
color: #6c6c6c;
height: 30px;
line-height: 30px;
text-align: left;
background-color: #F5F5F5;
}
/*當(dāng)光標(biāo)移動(dòng)到<a>范圍時(shí)的顯示效果,用絕對(duì)定位來(lái)顯示隱藏的導(dǎo)航按鈕*/
.header_right a:hover ul {
display: block;
position: absolute;
}
/*選擇到隱藏的導(dǎo)航按鈕時(shí)的顯示效果*/
ul li:hover{
background-color: #C3C3C3;
color: #FF5000;
}
</style>
</head>
<body>
<div class="header">
<div class="header_content">
<div class="header_left">
<a href="" class="header_a">中國(guó)大陸   <i class="fa fa-angle-down"></i></a>
<a href="" style="color: #FF5000">親,請(qǐng)登錄</a>
<a href="">免費(fèi)注冊(cè)</a>
<a href="">手機(jī)逛淘寶</a>
</div>
<div class="header_right">
<a href="" class="header_a">我的淘寶<i class="fa fa-angle-down"></i>
<ul class="header_right_a">
<li>已買(mǎi)到的寶貝</li>
<li>我的足跡</li>
</ul>
</a>
<a href="" ><i class="fa fa-shopping-cart" style="color: #FF5000"></i>   購(gòu)物車(chē)</a>
<a href="" class="header_a"><span class="fa fa-star"></span>   收藏夾<i class="fa fa-angle-down"></i></a>
<a href="" class="header_a">商品分類(lèi)</a>
<a href="" class="header_a">賣(mài)家中心   <i class="fa fa-angle-down"></i></a>
<a href="" class="header_a">聯(lián)系客服</a>
</div>
<div class="clear"></div>
</div>
</div>
</body>
</html>
這個(gè)頁(yè)面有曾經(jīng)學(xué)習(xí)過(guò)的position絕對(duì)定位,有無(wú)序列表的使用,有盒子模型的應(yīng)用,雖然只有一個(gè)導(dǎo)航欄,卻用到很多知識(shí)點(diǎn)才能完成,過(guò)程中要不斷調(diào)試css樣式才能實(shí)現(xiàn)最終效果,有時(shí)候忘記了屬性還要去w3c查,感覺(jué)練習(xí)量不夠,常用的屬性可以直接敲出,但是少用的還是要查,現(xiàn)在學(xué)到的才是靜態(tài)頁(yè)面,一定要多花時(shí)間練習(xí),多做。
添削の先生:查無(wú)此人添削時(shí)間:2019-05-05 09:36:52
先生のまとめ:完成的不錯(cuò)。常用的css樣式,可以寫(xiě)到一個(gè)公用文件里,隨時(shí)可以使用。繼續(xù)加油。