
批改狀態(tài):合格
老師批語:對頁面的基本控制技術(shù), 是宏觀上知識 , 對于字體大小顏色等細(xì)節(jié), 還是要根據(jù)自己喜愛決定
因為工作原因,沒有能及完成相關(guān)學(xué)習(xí)任務(wù),后面會盡快補上。
下面是使用flex布局,完成的三個簡單例子,分別依次按照分頁、二手商品、評論回復(fù)順序編寫,每個項目有又分為 效果圖、布局思路、HTML代碼和CSS代碼幾個部分。
首先,將包裹分頁的容器轉(zhuǎn)換為“彈性盒子”容器(container),然后讓整個盒子居中顯示,并且將盒子內(nèi)容的空間平局分配個盒子里面的項目(item),然后的a便簽中的文本進(jìn)行樣式調(diào)整,包括文本水平以及垂直居中,字體大小等,最后個鼠標(biāo)動作添加劃過特效(手型、陰影等)。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>公共翻頁標(biāo)簽</title>
<link rel="stylesheet" href="public_paginate.css">
</head>
<body>
<div class="public-paginate">
<a href=""><</a>
<a href="">1</a>
<a href="">2</a>
<a href="">3</a>
<a href="">4</a>
<a href="">5</a>
<a href="">6</a>
<a href="">7</a>
<a href="">8</a>
<a href="">></a>
</div>
</body>
</html>
/*引入公共初始化標(biāo)簽樣式文件*/
@import "public_reset.css";
.public-paginate{
width: 1200px;
height: 60px;
display: flex;
flex-flow: row nowrap;
/*設(shè)置子元素在主軸上的對齊方式*/
justify-content: center;
/*設(shè)置子元素在交叉軸上的對齊方式*/
align-items: center;
}
.public-paginate > a{
width: 60px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 14px;
margin: 0 5px;
border-radius: 5px;
background-color: #fff;
}
.public-paginate > a:hover{
font-size: 1.2em;
font-weight: bolder;
color: #fff;
background-color: #0086b3;
/*陰影效果:
box-shadow: h-shadow v-shadow blur spread color inset.
h-shadow: 陰影的水平位置
v-shadow:陰影的垂直位置
blur:陰影的模糊半徑
spread:陰影的半徑
color:陰影的顏色
inset:將外部陰影改成內(nèi)部陰影【outset反過來】
*/
box-shadow: 0 0 5px #888888;
}
首先,有一個包裹最外面的大盒子BOX(container),在打盒子里面有3 行項目(item),其中 row-1 標(biāo)題1、row-2 標(biāo)題2+導(dǎo)航、row-3(BOX-2)。
row-3(BOX-2)西面,又包含3個盒子(BOX-3),其中一個是商品的圖片和價格等,另外一個是快速入口。同時因為商品圖片格式等是一致的所以就又是一個盒子(BOX-4),而快速入口下面的廣告部分和上面的方向不一致,所以單拿出來做一個盒子(BOX-4。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>公共二手商品頭部列表</title>
<link rel="stylesheet" href="public_second_hand.css">
</head>
<body>
<div class="public-second-hand">
<!-- 頭部標(biāo)題1-->
<div class="title1">
<span>搶好貨</span>
<span>0低價,便捷,安全,快速</span>
</div>
<!-- 頭部標(biāo)題2-->
<div class="title2">
<span>熱門分類</span>
<a href="">美女寫真</a>
<a href="">日本美女</a>
<a href="">美國美女</a>
<a href="">國內(nèi)美女</a>
<a href="">AV美女</a>
</div>
<!-- 二手商品列表以及快速入口-->
<div class="hand-content">
<!-- 商品列表-->
<div class="hand-list">
<div class="list-goods">
<img src="../../../1220/images/shop/shop1.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop2.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop3.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop4.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop5.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop6.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop7.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
<div class="list-goods">
<img src="../../../1220/images/shop/shop8.jpg" alt="">
<span>美女性感寫真海報墻藝術(shù)裝飾、畫貼--圖1</span>
<div class="goods-price">
<span>¥345</span>
<span>美女</span>
</div>
</div>
</div>
<!-- 快速入口-->
<div class="quick">
<div class="quick-entry">
<a href=""><img src="../../../1220/images/ad/1.png" alt=""></a>
<a href=""><img src="../../../1220/images/ad/2.png" alt=""></a>
<a href=""><img src="../../../1220/images/ad/3.png" alt=""></a>
<a href=""><img src="../../../1220/images/ad/4.png" alt=""></a>
</div>
<div class="quick-ad">
<img src="../../../1220/images/ad/image.png" alt="">
<img src="../../../1220/images/ad/ad2.jpg" alt="">
</div>
</div>
</div>
</div>
</body>
</html>
CSS代碼
/*引入公共重置標(biāo)簽樣式文件*/
@import "public_reset.css";
/*外層div轉(zhuǎn)彈性盒子*/
.public-second-hand{
width: 1260px;
height: 530px;
background-color: #fff;
border-radius: 5px;
font-size: 13px;
color: #555555;
display: flex;
margin: 0 auto;
flex-flow: column nowrap;
}
.public-second-hand:hover{
box-shadow: 0 0 5px #888888;
}
/*頭部標(biāo)題1 樣式*/
.public-second-hand >.title1{
height: 40px;
line-height: 40px;
text-align: left;
}
.public-second-hand >.title1 >span:first-of-type{
color: #404040;
font-size: 1.4rem;
margin: 0 10px;
}
.public-second-hand >.title1 >span:last-of-type{
color: red;
padding-left: 16px;
}
/*頭部標(biāo)題2 以及分類導(dǎo)航樣式*/
.public-second-hand >.title2{
height: 40px;
margin: 10px 10px;
border-top: 1px solid #cccccc;
}
.public-second-hand >.title2 >span{
color: red;
font-size: 1.4rem;
}
.public-second-hand >.title2 >a{
margin: 0 10px;
}
.public-second-hand >.title2> a:hover {
color: lightcoral;
cursor: pointer;
}
/*商品列表與快速入口的大盒子*/
.public-second-hand >.hand-content{
height: 420px;
display: flex;
margin: 0 5px;
}
/*商品列表小盒子*/
.public-second-hand> .hand-content >.hand-list{
width: 850px;
height: 420px;
display: flex;
flex-flow: row wrap;
}
/*商品圖片與介紹*/
.list-goods{
width: 200px;
height: 120px;
display: flex;
flex-flow: column nowrap;
margin: 0 5px;
}
.list-goods > img{
width: 190px;
height: 120px;
border-radius: 4px;
}
/*價格*/
.goods-price{
text-align: center;
display: flex;
}
.goods-price >span:first-of-type{
color: red;
font-weight: bolder;
}
.goods-price >span:last-of-type{
color: #fff;
background-color: #669900;
margin-left: auto;
}
/*快速入口小盒子*/
.public-second-hand> .hand-content >.quick{
width: 410px;
height: 420px;
display: flex;
flex-flow: column wrap;
}
.quick-entry{
display: flex;
flex-flow: row wrap;
justify-content: space-evenly;
}
.quick-entry a{
margin-top: 5px;
}
.quick-entry a img{
width: 190px;
height: 120px;
}
.quick-ad{
display: flex;
flex-flow: column nowrap;
margin: 0 auto;
}
.quick-ad >img{
width: 380px;
height: 65px;
}
效果圖
布局思路
首先,將模塊分成兩個部分,即評論區(qū)和回復(fù)區(qū)。因為都縱向排列,所以盒子基本都是flex-flow: column nowrap;
,而評論區(qū)的文本域需要鋪滿剩余空間,所以flex:auto;resize: none;
其次,在回復(fù)內(nèi)容部分,因為回復(fù)點贊在另一個,所以最后這一樣也要轉(zhuǎn)化為盒子,并且包裹回復(fù)的<span>
元素,需要margin-left: auto;
HTML代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>公共組件-評論回復(fù)</title>
<link rel="stylesheet" href="public_comments_reply.css">
</head>
<body>
<div class="public-comments-reply">
<!-- 評論區(qū)域-->
<div class="comments">
<span>我要評論</span>
<div class="comments-content">
<img src="../../../1220/images/user.png" alt="">
<label for="comments_text"></label>
<textarea name="comments_text" id="comments_text" cols="30" rows="10"></textarea>
</div>
<button>發(fā)表評論</button>
</div>
<!-- 回復(fù)區(qū)域-->
<div class="reply">
<span>最新回復(fù)</span>
<!-- 評論回復(fù)列表-->
<div class="reply-list">
<img src="../../../1220/images/user.png" alt="">
<!-- 評論內(nèi)容-->
<div class="reply-content">
<span>用戶昵稱</span>
<span>留言內(nèi)容:PHP中文網(wǎng)是一個有溫度、有內(nèi)容、有理想的學(xué)習(xí)平臺!</span>
<!-- 回復(fù)時間與點贊-->
<div>
<span>2019-12-23 14:52:49發(fā)布</span>
<span><i class="iconfont"></i>回復(fù)</span>
</div>
</div>
</div>
<div class="reply-list">
<img src="../../../1220/images/user.png" alt="">
<!-- 評論內(nèi)容-->
<div class="reply-content">
<span>用戶昵稱</span>
<span>留言內(nèi)容:PHP中文網(wǎng)是一個有溫度、有內(nèi)容、有理想的學(xué)習(xí)平臺!</span>
<!-- 回復(fù)時間與點贊-->
<div>
<span>2019-12-23 14:52:49發(fā)布</span>
<span><i class="iconfont"></i>回復(fù)</span>
</div>
</div>
</div>
<div class="reply-list">
<img src="../../../1220/images/user.png" alt="">
<!-- 評論內(nèi)容-->
<div class="reply-content">
<span>用戶昵稱</span>
<span>留言內(nèi)容:PHP中文網(wǎng)是一個有溫度、有內(nèi)容、有理想的學(xué)習(xí)平臺!</span>
<!-- 回復(fù)時間與點贊-->
<div>
<span>2019-12-23 14:52:49發(fā)布</span>
<span><i class="iconfont"></i>回復(fù)</span>
</div>
</div>
</div>
<div class="reply-list">
<img src="../../../1220/images/user.png" alt="">
<!-- 評論內(nèi)容-->
<div class="reply-content">
<span>用戶昵稱</span>
<span>留言內(nèi)容:PHP中文網(wǎng)是一個有溫度、有內(nèi)容、有理想的學(xué)習(xí)平臺!</span>
<!-- 回復(fù)時間與點贊-->
<div>
<span>2019-12-23 14:52:49發(fā)布</span>
<span><i class="iconfont"></i>回復(fù)</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
CSS代碼
/*引入公共重置標(biāo)簽樣式文件*/
@import "public_reset.css";
.public-comments-reply{
width: 1200px;
height: 720px;
font-size: 13px;
color: #555555;
background-color: #fff;
display: flex;
flex-flow: column nowrap;
margin: 0 auto;
}
.public-comments-reply img{
width: 50px;
height: 50px;
border-radius: 2px;
box-shadow: 0 0 2px #888888;
margin: 0 14px;
}
/*評論區(qū)域樣式*/
.public-comments-reply >.comments{
width: 1160px;
height: 320px;
display: flex;
flex-flow: column nowrap;
justify-content: flex-start;
border-top: 1px solid #cccccc;
margin: 10px 10px;
}
/*評論區(qū)標(biāo)題*/
.public-comments-reply >.comments >span:first-of-type{
height: 60px;
line-height: 60px;
font-weight: bolder;
}
/*評論切頭像與評論內(nèi)容*/
.comments >.comments-content{
height: 200px;
display: flex;
}
/*文本域樣式*/
.comments >.comments-content >textarea{
height: 200px;
flex:auto;
/*文本域不予許調(diào)整大小*/
resize: none;
}
.comments >.comments-content >textarea:hover{
box-shadow: 0 0 5px #888888;
}
/*評論區(qū)提交按鈕按*/
.public-comments-reply >.comments >button{
width: 130px;
height: 34px;
border: none;
line-height: 34px;
text-align: center;
color: #fff;
background-color: #ff2017;
margin-top: 20px;
margin-left: auto;
}
.public-comments-reply >.comments >button:hover {
background-color: #178cee;
cursor: pointer;
box-shadow: 0 0 2px #888888;
}
/*回復(fù)區(qū)域樣式*/
.public-comments-reply >.reply{
width: 1160px;
height: 360px;
display: flex;
flex-flow: column nowrap;
margin:0 10px;
}
.public-comments-reply >.reply >span{
height: 50px;
line-height: 50px;
font-weight: bolder;
}
/*回復(fù)內(nèi)容 頭像+內(nèi)容*/
.public-comments-reply>.reply>.reply-list{
height: 70px;
display: flex;
flex-flow: row nowrap;
margin-bottom: 18px;
}
.public-comments-reply>.reply>.reply-list> img{
/*子元素交叉軸居中*/
align-self: center;
}
/*回復(fù)內(nèi)容*/
.public-comments-reply>.reply>.reply-list>.reply-content{
flex:auto;
display: flex;
flex-flow: column nowrap;
justify-content: space-around;
}
.public-comments-reply>.reply>.reply-list>.reply-content >div{
display: flex;
}
.public-comments-reply>.reply>.reply-list>.reply-content >div >span:last-of-type{
margin-left: auto;
}
.public-comments-reply>.reply>.reply-list>.reply-content >div >span> i{
color: #ff2017;
font-size: 20px;
margin-right: 10px;
}
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號