
批改狀態(tài):合格
老師批語:看來是明白了
<div class="box">
<div class="header">
<a href="#">LOGO</a>
<a href="">產品</a>
<a href="">定價</a>
<a href="">解決方案</a>
<a href="">支持</a>
<a href="">下載</a>
<a href="">免費使用</a>
</div>
<div class="container">
<div class="aside">我在左邊</div>
<div class="main">我是內容區(qū)</div>
<div class="aside">我在右邊</div>
</div>
<div class="footer">
<p><a href="">使用條款</a> <a href="">隱私政策</&a></p>
<p>霏夢公司 Copyright ? 2020 京ICP備080000000號</p>
</div>
</div>
CSS代碼如下:
<style>
/* 初始化 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* body轉為flex */
body{
min-width: 800px;
display: flex;
/* 垂直不換行 */
flex-flow: row nowrap;
justify-content: center;
}
/* box轉為flex */
.box {
min-width: 800px;
display: flex;
/* 垂直不換行 */
flex-flow: column nowrap;
}
.header,
.footer{
height: 50px;
border: 1px solid black;
}
.header{
display: flex;
/* 交叉軸上垂直居中顯示 */
align-items: center;
}
.header > a {
color: coral;
text-decoration: none;
flex: 0 1 100px;
/* 文本居中 */
text-align: center;
}
.header > a:first-of-type{
margin-right: 50px;
}
.header > a:last-of-type{
/* 免費使用 往最右 */
margin-left: auto;
}
/* 鼠標懸停時忽略logo */
.header >a:hover:not(:first-of-type){
background-color: chartreuse;
color:darkblue;
}
.container {
display: flex;
min-height: 300px;
margin: 10px auto;
justify-content: center;
text-align: center;
}
.container > .aside,
.container>.main{
border: 1px solid darkorange;
padding: 10px;
}
.container >.aside{
flex:0 0 200px;
}
.container >.main{
flex: 0 0 380px;
margin: 0 10px;
}
.footer{
display: flex;
/* 垂直方向不換行*/
flex-flow: column nowrap;
text-align: center;
}
.footer > p > a{
text-decoration: none;
}
</style>
html代碼如下:
<body>
<!-- 頁眉 -->
<header>
<a href="">LOGO</a>
<span class="iconfont"></span>
</header>
<!-- 輪播區(qū)域 -->
<div class="slider">
<img src="static/images/banner.jpg" alt="" />
</div>
<!-- 主要導航區(qū)域 -->
<div class="nav">
<div>
<a href=""><img src="static/images/link1.webp" alt="" /></a>
<a href="">天貓超市</a>
</div>
<div>
<a href=""><img src="static/images/link2.webp" alt="" /></a>
<a href="">服裝百貨</a>
</div>
<div>
<a href=""><img src="static/images/link3.webp" alt="" /></a>
<a href="">數碼電器</a>
</div>
<div>
<a href=""><img src="static/images/link1.webp" alt="" /></a>
<a href="">圖書精品</a>
</div>
<div>
<a href=""><img src="static/images/link1.webp" alt="" /></a>
<a href="">天貓超市</a>
</div>
<div>
<a href=""><img src="static/images/link2.webp" alt="" /></a>
<a href="">服裝百貨</a>
</div>
<div>
<a href=""><img src="static/images/link3.webp" alt="" /></a>
<a href="">數碼電器</a>
</div>
<div>
<a href=""><img src="static/images/link1.webp" alt="" /></a>
<a href="">圖書精品</a>
</div>
</div>
<h2>
商品熱銷區(qū)
<span class="iconfont hot" style="color: coral;"></span>
</h2>
<div class="goods-hot">
<div class="goods-img">
<a href=""><img src="static/images/goods1.jpg" alt="" /></a>
<p>Apple iPhone 11 128G</p>
<div>
<span>6299 元</span>
<span class="iconfont hot"></span>
</div>
</div>
<div class="goods-img">
<a href=""><img src="static/images/goods1.jpg" alt="" /></a>
<p>Apple iPhone X 512G</p>
<div>
<span>8299 元</span>
<span class="iconfont hot"></span>
</div>
</div>
<div class="goods-img">
<a href=""><img src="static/images/goods2.jpg" alt="" /></a>
<p>華為筆記本電腦</p>
<div>
<span>5699 元</span>
<span class="iconfont hot"></span>
</div>
</div>
<div class="goods-img">
<a href=""><img src="static/images/goods2.jpg" alt="" /></a>
<p>小米筆記本電腦</p>
<div>
<span>3999 元</span>
<span class="iconfont hot"></span>
</div>
</div>
<div class="goods-img">
<a href=""><img src="static/images/goods2.jpg" alt="" /></a>
<p>聯想筆記本電腦</p>
<div>
<span>4399 元</span>
<span class="iconfont hot"></span>
</div>
</div>
</div>
<!-- 商品列表 -->
<h2 class="title">
商品列表
<span class="iconfont hot" style="color: tomato;"></span>
</h2>
<div class="goods-list">
<div class="goods-desc">
<a href=""><img src="static/images/goods4.jpg" alt="" /></a>
<a href=""
>[白條24期免息]Apple蘋果iPhone 11 手機 128G 全網通, 免費領取500元話費,
今天17:00下單,明晨12:00之前送達,7天無理由退貨,官方提供售后,測試的</a
>
</div>
<div class="goods-desc">
<a href=""><img src="static/images/goods3.jpg" alt="" /></a>
<a href=""
>西門子泳衣機 免費領取500元話費,
今天17:00下單,明晨12:00之前送達,7天無理由退貨,官方提供售后,測試的</a
>
</div>
<div class="goods-desc">
<a href=""><img src="static/images/goods5.png" alt="" /></a>
<a href=""
>這是一部全屏手機,價格只要1元,顏色很多,免費3年維修更換,快遞免費,上門更換</a
>
</div>
<div class="goods-desc">
<a href=""><img src="static/images/goods2.jpg" alt="" /></a>
<a href=""
>ROG冰銳2 15.6英寸240Hz電競屏高色域輕薄便攜游戲本筆記本電腦(R9-4900HS
8核7nm 16G 1TSSD RTX2060MaxQ</a
>
</div>
</div>
<!-- 頁腳 -->
<footer>
<a href="">
<span class="iconfont hot"></span>
<span>首頁</span>
</a>
<a href="">
<span class="iconfont hot"></span>
<span>分類</span>
</a>
<a href="">
<span class="iconfont hot"></span>
<span>購物車</span>
</a>
<a href="">
<span class="iconfont hot"></span>
<span>未登錄</span>
</a>
</footer>
</body>
css代碼如下 :
<style>
/* 初始化 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
color: grey;
}
html {
/* 可視區(qū)域的寬和高 */
width: 100vw;
height: 100vh;
font-size: 14px;
/* font-family:Arial, Helvetica, sans-serif; */
color: grey;
}
body {
min-width: 360px;
background-color: white;
display: flex;
flex-flow: column nowrap;
}
header {
color: white;
background-color: #333;
height: 30px;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
width: 100vw;
padding: 0 10px;
}
.slider {
height: 180px;
}
.slider > img {
height: 100%;
}
.nav {
height: 200px;
margin-bottom: 10px;
display: flex;
/* 轉為多行容器 */
flex-flow: row wrap;
align-content: space-around;
}
.nav > div {
width: 25vw;
display: flex;
flex-flow: column nowrap;
text-align: center;
}
.nav > div > a img {
width: 50%;
}
.title {
text-align: center;
font-size: 1.6rem;
font-weight: normal;
}
.goods-hot {
border-top: 1px solid #cdcdcd;
margin-top: 10px;
font-size: 0.8rem;
display: flex;
/* 水平多行容器 */
flex-flow: row wrap;
}
.goods-hot img {
width: 100%;
}
.goods-hot > .goods-img {
/* 內邊距并重置大小 */
padding: 10px;
box-sizing: border-box;
/* 允許放大不允許縮小,否則項目不會換行,多行容器失效 */
flex: 1 0 30vw;
/* 轉為flex */
display: flex;
/* 主軸垂直且不允許換行 */
flex-flow: column nowrap;
justify-content: center;
}
/* 轉flex,主軸上排列對齊方式 */
.goods-hot > .goods-img > div {
display: flex;
/* 分散對齊 */
justify-content: space-around;
}
.goods-list {
padding: 10px;
border: 1px solid #cdcdcd;
margin-top: 10px;
font-size: 14px;
display: flex;
/* 主軸必須是垂直 */
flex-flow: column nowrap;
}
.goods-list > .goods-desc {
display: flex;
margin: 10px 0;
}
.goods-list > .goods-desc > a {
padding: 10px 0;
box-sizing: border-box;
}
/* 圖片全部適應項目空間 */
.goods-list > .goods-desc > a > img {
width: 100%;
}
.goods-list > .goods-desc > a:last-of-type:hover {
color: seagreen;
}
footer {
color: #666;
height: 60px;
background-color: #efefef;
border-top: 1px solid #666;
position: fixed;
bottom: 0;
width: 100vw;
display: flex;
justify-content: space-around;
}
footer > a {
margin-top: 10px;
display: flex;
/* 垂直排列不換行 */
flex-flow: column nowrap;
/* 交叉軸項目居中顯示 */
align-items: center;
}
footer a > span:first-of-type {
font-size: 1.6rem;
}
.hot {
/* 底部圖標的顏色 */
color: coral;
}
</style>
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號