????:<!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)簽定義一個固定樣式*/
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)行向左浮動*/
.header_left {
height: 40px;
float: left;
}
/*設(shè)置左邊導(dǎo)航欄按鈕間的間距*/
.header_left a {
margin-right: 3px;
}
/*設(shè)置右邊導(dǎo)航欄的高度,并進(jìn)行向右浮動*/
.header_right {
height: 40px;
float: right;
}
/*設(shè)置右邊導(dǎo)航欄按鈕間的間距*/
.header_right a {
margin-left: 3px;
}
/*將.header_a類選擇器中元素該為行內(nèi)塊元素,并設(shè)置文本居中顯示*/
.header_a{
display: inline-block;
height: 40px;
width: 80px;
text-align: center;
position: relative;
}
/*添加光標(biāo)停留時.header_a類標(biāo)簽的顯示效果*/
.header_a:hover {
/*line-height: 40px;*/
background-color: white;
}
/*添加光標(biāo)停留時<a>的顯示效果*/
a:hover {
color: #FF5000;
}
/*設(shè)置無序列表的隱藏和border*/
.header_right_a {
border:1px solid #F5F5F5;
border-top: none;
display: none;
}
/*取消無序列表的小點(diǎn),設(shè)置列表內(nèi)容的高度和文字向左對齊*/
li {
list-style: none;
color: #6c6c6c;
height: 30px;
line-height: 30px;
text-align: left;
background-color: #F5F5F5;
}
/*當(dāng)光標(biāo)移動到<a>范圍時的顯示效果,用絕對定位來顯示隱藏的導(dǎo)航按鈕*/
.header_right a:hover ul {
display: block;
position: absolute;
}
/*選擇到隱藏的導(dǎo)航按鈕時的顯示效果*/
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">中國大陸   <i class="fa fa-angle-down"></i></a>
<a href="" style="color: #FF5000">親,請登錄</a>
<a href="">免費(fèi)注冊</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>已買到的寶貝</li>
<li>我的足跡</li>
</ul>
</a>
<a href="" ><i class="fa fa-shopping-cart" style="color: #FF5000"></i>   購物車</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">商品分類</a>
<a href="" class="header_a">賣家中心   <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>
這個頁面有曾經(jīng)學(xué)習(xí)過的position絕對定位,有無序列表的使用,有盒子模型的應(yīng)用,雖然只有一個導(dǎo)航欄,卻用到很多知識點(diǎn)才能完成,過程中要不斷調(diào)試css樣式才能實現(xiàn)最終效果,有時候忘記了屬性還要去w3c查,感覺練習(xí)量不夠,常用的屬性可以直接敲出,但是少用的還是要查,現(xiàn)在學(xué)到的才是靜態(tài)頁面,一定要多花時間練習(xí),多做。
?? ???:查無此人?? ??:2019-05-05 09:36:52
???? ??:完成的不錯。常用的css樣式,可以寫到一個公用文件里,隨時可以使用。繼續(xù)加油。