abstrait:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>淘寶布局</title><html lang="en"><head><meta charset="
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>淘寶布局</title>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>淘寶布局</title>
<link rel="stylesheet" href="staic/css/font-awesome-4.7.0/font-awesome-4.7.0/css/font-awesome.min.css">
<style>
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
color: #3C3C3C;
font-size: 12px;
}
li{
list-style: none;
}
.clear {
clear: both;
}
.header {
width: 100%;
background-color: #f5f5f5;
}
.header_content {
width: 1197px;
margin: 0 auto;
line-height: 35px;
}
.header_left {
height: 35px;
float: left;
}
.header_right {
height: 35px;
float: right;
}
.header_a {
display: inline-block;
width: 90px;
height: 35px;
text-align: center;
}
.header_a {
display: inline-block;
width: 90px;
height: 35px;
text-align: center;
}
.header_a:hover {
display: inline-block;
width: 90px;
height: 35px;
text-align: center;
background-color: #fff;
position: relative;
}
.header a {
margin-right: 5px;
}
.header a:hover {
color: #f22e00 !important;
}
.header_a ul{
border: 1px solid #f5f5f5;
display: none;
position: absolute;
width: 100px;
border-top:none;
}
.header_a:hover ul{
display: block;
}
.header_a ul li{
color: #6c6c6c;
height: 30px;
line-height: 30px;
text-align: left;
padding: 0 3px;
}
.header_a ul li:hover{
background-color: #f5f5f5;
}
</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: #f22e00">親,請登錄</a>
<a href="">免費注冊</a>
<a href="">手機逛淘寶</a>
</div>
<div class="header_right">
<a href="" class="header_a">我的淘寶 <i class="fa fa-angle-down"></i>
<ul>
<li>已買到的寶貝</li>
<li>足跡</li>
</ul>
</a>
<a href="" class="header_a"><i class="fa fa-shopping-cart"></i> 購物車 <i class="fa fa-angle-down"></i></a>
<a href=""><i class="fa fa-star"></i> 收藏夾</a>
<a href="">商品分類</a>
<a href="" class="header_a">賣家中心 <i class="fa fa-angle-down"></i>
<ul>
<li>免費開店</li>
<li>已賣出的寶貝</li>
<li>已買到的寶貝</li>
</ul>
</a>
<a href="" class="header_a">聯(lián)系客服 <i class="fa fa-angle-down"></i>
<ul>
<li>消費者客服</li>
<li>賣家客服</li>
</ul>
</a>
<a href="">網(wǎng)站導航</a>
</div>
</div>
<div class="clear"></div>
</div>
</body>
</html>
總結:實現(xiàn)下拉的原理即改變下拉部分的display屬性,另在下拉ul的父級元素設置一個相對定位,在給ul一個絕對定位可以讓ul排版正確而不會擠掉后面的元素
Professeur correcteur:韋小寶Temps de correction:2019-01-31 09:15:07
Résumé du professeur:寫的很不錯 css實現(xiàn)下拉效果還是比較簡單的 課后記得要多練習哦 繼續(xù)加油吧