四、品優購首頁製作_header區域
阿新 • • 發佈:2021-05-08
程式碼下載地址:https://gitee.com/bitaotao/quality-shopping-static-page.git
#二、品優購首頁製作
2.1、header製作
-
header盒子必須要有高度
-
1號盒子是logo標誌定位
-
2號盒子是search搜尋模組定位
-
3號盒子是hotwords熱詞模組定位
-
4號盒子是shopcar購物車模組
- count統計部分用絕對定位做
- count統計部分不要給寬度,因為可能買的件數比較多,讓件數撐開就好了,給一個高度
- 一定注意左下角不是圓角,其餘三個是圓角 寫法: border-radius:7px 7px 7px 0
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>品優購</title >
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="./css/base.css">
<link rel="stylesheet" href="./css/common.css">
</head>
<body>
<!-- 快捷導航模組 start -->
<section class="shortcut">
<div class="w">
<div class="fl">
<ul>
<li>品優購歡迎您!</li>
<li>
<a href="#">請登入</a><a href="#">免費註冊</a>
</li>
</ul>
</div>
<div class="fr">
<ul>
<li>我的訂單</li>
<li></li>
<li class="arrow-icon">我的品優購</li>
<li></li>
<li>品優購會員</li>
<li></li>
<li>企業採購</li>
<li></li>
<li class="arrow-icon">關注品優購</li>
<li></li>
<li class="arrow-icon">客戶服務</li>
<li></li>
<li class="arrow-icon">網站導航</li>
</ul>
</div>
</div>
</section>
<!-- 快捷導航模組 end -->
<!-- header 頭部模組 start -->
<header class="header w">
<!-- logo模組 -->
<div class="logo">
<h1>
<a href="index.html">品優購商城</a>
</h1>
</div>
<!-- search搜尋模組 -->
<div class="search">
<input type="search" name="" id="" placeholder="語言開發">
<button>搜尋</button>
</div>
<!-- hotwords模組製作 -->
<div class="hotwords">
<a href="#" class="style_red">優惠購首發</a>
<a href="#">億元優惠</a>
<a href="#">9.9元團購</a>
<a href="#">美滿99減30</a>
<a href="#">辦公用品</a>
<a href="#">電腦</a>
<a href="#">通訊</a>
</div>
<!-- 購物車模組 -->
<div class="shopcar">
我的購物車
<i class="count">8</i>
</div>
</header>
<!-- header 頭部模組 end -->
</body>
</html>
common.css
/* 宣告字型圖示 這裡一定要注意路徑的變化 */
@font-face {
font-family: 'icomoon';
src: url('../fonts/icomoon.eot?tomleg');
src: url('../fonts/icomoon.eot?tomleg#iefix') format('embedded-opentype'),
url('../fonts/icomoon.ttf?tomleg') format('truetype'),
url('../fonts/icomoon.woff?tomleg') format('woff'),
url('../fonts/icomoon.svg?tomleg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
/* 版心 */
.w {
width: 1200px;
margin: 0 auto;
}
.fl {
float: left;
}
.fr {
float: right;
}
.style_red {
color: #c81623;
}
/* 快捷導航模組 */
.shortcut {
height: 31px;
line-height: 31px;
background-color: #f1f1f1;
}
.shortcut ul li {
float: left;
}
/* 選擇所有的偶數小li */
.shortcut .fr ul li:nth-child(even) {
width: 1px;
height: 12px;
background-color: #666;
margin: 9px 15px 0;
}
.arrow-icon::after {
content: '\e91e';
font-family: "icomoon";
margin-left: 6px;
}
/* header 頭部製作 */
.header {
position: relative;
height: 105px;
}
.logo {
position: absolute;
top: 25px;
width: 171px;
height: 61px;
}
.logo a {
display: block;
width: 171px;
height: 61px;
background: url(../images/logo.png) no-repeat;
/* font-size: 0; 京東的做法 */
/* 淘寶的做法讓文字隱藏 */
text-indent: -9999px;
overflow: hidden;
}
.search {
position: absolute;
left: 346px;
top: 25px;
width: 538px;
height: 36px;
border: 2px solid #b1191a;
}
.search input {
float: left;
width: 454px;
height: 32px;
padding-left: 10px;
}
.search button {
float: left;
width: 80px;
height: 32px;
background-color: #b1191a;
font-size: 16px;
color: #fff;
}
.hotwords {
position: absolute;
top: 66px;
left: 346px;
}
.hotwords a {
margin: 0 10px;
}
.shopcar {
position: absolute;
right: 60px;
top: 25px;
width: 140px;
height: 35px;
line-height: 35px;
text-align: center;
border: 1px solid #dfdfdf;
background-color: #f7f7f7;
}
.shopcar::before {
content: '\e93a';
font-family: 'icomoon';
margin-right: 5px;
color: #b1191a;
}
.shopcar::after {
content: '\e920';
font-family: 'icomoon';
margin-left: 10px;
}
.count {
position: absolute;
top: -5px;
left: 105px;
height: 14px;
line-height: 14px;
color: #fff;
background-color: #e60012;
padding: 0 5px;
border-radius: 7px 7px 7px 0;
}
base.css
/* 把我們所有標籤的內外邊距清零 */
html,body,ul,li,ol,dl,dd,dt,p,h1,h2,h3,h4,h5,h6,form,fieldset,legend,img,div {
margin: 0;
padding: 0;
/* css3盒子模型 */
box-sizing: border-box;
}
/* em 和 i 斜體的文字不傾斜 */
em,
i {
font-style: normal
}
/* 去掉li 的小圓點 */
li {
list-style: none
}
img {
/* border 0 照顧低版本瀏覽器 如果 圖片外面包含了連結會有邊框的問題 */
border: 0;
/* 取消圖片底側有空白縫隙的問題 */
vertical-align: middle
}
button {
/* 當我們滑鼠經過button 按鈕的時候,滑鼠變成小手 */
cursor: pointer
}
a {
color: #666;
text-decoration: none
}
a:hover {
color: #c81623
}
button,
input {
/* "\5B8B\4F53" 就是宋體的意思 這樣瀏覽器相容性比較好 */
font-family: Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
/* 預設有灰色邊框 我們需要手動去掉 */
border: 0;
outline: none;
}
body {
/* CSS3 抗鋸齒形 讓文字顯示的更加清晰 */
-webkit-font-smoothing: antialiased;
background-color: #fff;
font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
color: #666
}
.hide,
.none {
display: none
}
/* 清除浮動 */
.clearfix:after {
visibility: hidden;
clear: both;
display: block;
content: ".";
height: 0
}
.clearfix {
*zoom: 1
}