Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:box-sizing, 与padding, border的添加顺序无关, 只要加上就会有效
效果链接
https://zhhacker.com/1226/public/components/public/public_header/public_header.htmlhtml
代码如下:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>公共表头</title>
<link rel="stylesheet" href="public_header.css">
</head>
<body>
<div class="public-header">
<a href="">网站首页</a>
<a href="">专题</a>
<a href="">网站导航</a>
<a href="">二手商品</a>
<a href="">讨论区</a>
<span>
<a href=""><i class="iconfont icon-huiyuan2"></i></a>
<a href="">登录</a>
<a href="">免费注册</a>
</span>
</div>
</body>
</html>
css
代码如下:
@import url(../public_reset.css);
.public-header{
height: 44px;
background-color: black;
padding: 0 20px;
line-height: 44px;
display: flex;
}
.public-header a{
padding: 0 10px;
/*line-height: 44px;*/
color: #cccccc;
font-size: 16px;
}
.public-header > a:hover{
color: #404040;
background-color: #efefef;
/*font-size: 18px;*/
font-weight: bold;
}
.public-header > span {
margin-left: auto;
}
.public-header > span i.iconfont{
font-size: 1.3rem;
}
重置初始样式表
@import "iconfont.css";
*{
margin: 0;
padding: 0;
/*参考线*/
/*outline: 1px dashed red;*/
}
body{
font-size: 14px;
color: #555555;
background-color: #efefef;
}
a{
color: #404040;
text-decoration: none;
font-size: 13px;
}
li{
list-style: none;
}
老规矩效果,先放效果。特点:利用弹性盒子挤压实现鼠标滑动,突出图片效果
效果链接
https://zhhacker.com/1226/public/components/public/public_second_hand/public_second_hand.htmlhtml
代码如下:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>二手商品交易</title>
<!-- 引入头部标题样式-->
<link rel="stylesheet" href="../public_headline/public_headline.css">
<link rel="stylesheet" href="public_second_hand.css">
</head>
<body>
<!--引入头部标题-->
<div class="public-headline">
<span>二手交易</span>
</div>
<!--商品展示区-->
<div class="public-second-hand">
<div class="title1">
<a href="">抢好货</a>
<span>0低价,便捷,安全,快速</span>
</div>
<div class="title2">
<span>热门分类</span>
<a href="">美女写真</a>
<a href="">日本美女</a>
<a href="">美国美女</a>
<a href="">国内美女</a>
<a href="">AV美女</a>
</div>
<!-- 商品展示-->
<div class="goods">
<!-- 左边图片列表-->
<div class="good-list">
<div class="information">
<a href=""><img src="../../../images/shop/shop1.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图1</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop2.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图2</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop3.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图3</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop4.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图4</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop5.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图5</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop6.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图6</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop7.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图7</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="information">
<a href=""><img src="../../../images/shop/shop8.jpg" alt=""></a>
<a href="">美女性感写真海报墙艺术装饰画贴画图8</a>
<div>
<span>¥333</span>
<span>美女</span>
</div>
</div>
</div>
<!-- 右边快速入口+广告-->
<div class="quick-entry">
<div class="enter">
<a href=""><img src="../../../images/ad/1.png" alt=""></a>
<a href=""><img src="../../../images/ad/2.png" alt=""></a>
<a href=""><img src="../../../images/ad/3.png" alt=""></a>
<a href=""><img src="../../../images/ad/4.png" alt=""></a>
</div>
<div class="ads">
<a href=""><img src="../../../images/ad/image.png" alt=""></a>
<a href=""><img src="../../../images/ad/ad2.jpg" alt=""></a>
</div>
</div>
</div>
</div>
</body>
</html>
css
代码如下:
@import "../public_reset.css";
.public-second-hand {
width: 1200px;
padding: 10px;
box-sizing: border-box;
margin: auto;
background-color: #ffffff;
border-radius: 10px;
display: flex;
/*竖直排列*/
flex-flow: column nowrap;
}
.public-second-hand:hover{
box-shadow: 0 0 3px #888;
}
.public-second-hand > .title1 {
height: 50px;
border-bottom: 1px solid #cccccc;
box-sizing: border-box;
}
.public-second-hand > .title1 a{
padding: 0 5px;
font-size: 23px;
box-sizing: border-box;
}
.public-second-hand > .title1 span{
margin-left: 20px;
color: #ff0000;
}
.public-second-hand > .title2 {
height: 55px;
}
.public-second-hand > .title2 span{
padding: 0 5px;
color: red;
font-size: 23px;
box-sizing: border-box;
}
.public-second-hand > .title2 a{
padding: 5px;
box-sizing: border-box;
}
.public-second-hand > .title2 a:hover{
color: #f08080;
}
.public-second-hand > .goods {
height: 440px;
padding: 0 5px;
box-sizing: border-box;
display: flex;
flex-flow: row nowrap;
}
.public-second-hand > .goods > .good-list{
padding: 0 10px;
box-sizing: border-box;
flex-basis: 800px;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
.public-second-hand > .goods > .good-list > .information{
width: 178px;
height: 200px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
}
.public-second-hand > .goods > .good-list > .information img{
width: 178px;
height: 122px;
box-shadow: 0 0 2px #f08080;
}
/*利用弹性盒子增加图片放大效果*/
.public-second-hand > .goods > .good-list > .information img:hover{
box-shadow: 0 0 3px red;
height: 125px;
}
.public-second-hand > .goods > .good-list > .information div{
display: flex;
justify-content: space-between;
/*outline: 1px solid red;*/
}
.public-second-hand > .goods > .good-list > .information span:first-child{
color: red;
}
.public-second-hand > .goods > .good-list > .information span:last-child{
background-color: #55ce9f;
color: white;
padding: 0 5px;
}
.public-second-hand > .goods >.quick-entry{
padding: 0 5px 10px;
box-sizing: border-box;
flex-basis: 400px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
}
.public-second-hand > .goods >.quick-entry> .enter {
flex-basis: 300px;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
/*增加图片放大效果*/
.public-second-hand > .goods >.quick-entry> .enter img:hover{
width: 205px;
height: 128px;
box-shadow: 0 0 3px #55ce9f;
}
.public-second-hand > .goods >.quick-entry> .ads{
flex-basis: 140px;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
}
.public-second-hand > .goods >.quick-entry> .ads img{
}
头部标题css
代码
@import "../public_reset.css";
.public-headline{
padding: 30px 0;
text-align: center;
}
.public-headline span{
line-height: 44px;
padding-bottom: 6px;
font-size: 30px;
font-weight: bold;
border-bottom: 2px solid #ff0000;
}
1.box-sizing: border-box; 参考网上资料,控制影响值为padding和border,我理解是使用padding或者border之后添加box-sizing: border-box; 但实际情况并不是每次都需要,老师能不能简单点帮我总结一下,什么时候必须使用box-sizing: border-box;?