结构为类选择器


伪元素选择器

PxCook
盒子模型 (内外边距,边框)







内外边距合并,塌陷问题



元素溢出

圆角


阴影:
模糊半径:越大越模糊,也就是越柔和


案例一:产品卡片



html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>产品卡片</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing:border-box;/*不希望撑大盒子,启动内减模式*/
}
body{
background-color:#f1f1f1;
}
.product{
margin: 50px auto;
/* 因为内容都是居中显示,所以直接添加padding效果 */
padding: 40px;
width: 270px;
height: 253px;
background-color: #fff;
text-align: center;
border-radius:10px;
}
.product h4{
margin-top: 20px;
margin-bottom: 12px;
font-size: 18px;
color: #333;
font-weight:400;
}
.product p {
font-size:12px;
color: #555;
}
</style>
</head>
<body>
<div class="product">
<img src="./images/image.png" alt="">
<h4>抖音直播SKD</h4>
<p>包含抖音直播刊播功能</p>
</div>
</body>
</html>
案例二:新闻列表

清除默认样式 :
所有标签内外边距,内减防止因为内边距和边框将盒子撑大

完成整个大盒子以及新闻框盒子样式:
大盒子:
- 外边距左右设置为 auto让整个大盒子居中显示
新闻框盒子:
- 新闻框盒子作为大盒子的儿子,宽度是一样的,不必再设置
- 新闻框左边边框是没有的
- 新闻框中链接标签 a:
想要贴近新闻框,-1px 往下
a标签是行内元素跟span标签一样,设置宽高不显示,所以display转换为块级元素
同样该 块 右边没有边框

完成内容模块,类bd,li标签中包含 a 标签:
方形点和图片作为背景图:
- 方形点作为整个 li 标签背景图,左内边距空出来正好显示方形点
- 图片作为 a 标签内容的背景图片 ,左内边距空出来正好显示图片
单个属性,复合属性:背景图,平铺方式,放置位置

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>新闻列表</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
li{
/* 将li标签的项目符号清除掉 */
list-style:none;
}
a{
/* 将a标签的下划线清除掉 */
text-decoration: none;
}
.news{
margin: 100px auto;
width: 360px;
height: 200px;
/* background-color: pink; */
}
.news .hd{
height: 34px;
background-color: #eee;
border: 1px solid #dbdee1;
border-left: none;
}
.news .hd a{
/* -1盒子向上移动 */
margin-top: -1px;
/* a标签是行内元素,加宽高不生效 */
/* div块标签默认是父级元素的百分百,那么宽度直接省略 */
display: block;
border-top: 3px solid #ff8400;
border-right: 1px solid #bddee1;
width: 48px;
height: 34px;
background-color: #fff;
text-align: center;
line-height: 34px;
font-size: 14px;
color: #333;
}
.news .bd{
padding: 5px;
}
.news .bd li{
padding-left: 15px;
background-image: url(./images/square.png);
background-repeat: no-repeat;
/* 背景图位置水平设置为0,垂直设置为center */
background-position: 0 center;
}
.news .bd li a{
padding-left: 20px;
background:url(./images/img.gif) no-repeat 0 center;
font-size: 12px;
color: #666;
}
.news .bd li a:hover{
color:#ff8400;
}
</style>
</head>
<body>
<!-- 新闻区域 包含标题 和 内容 -->
<div class="news">
<!-- 标题 -->
<div class="hd"><a href="">新闻</a></div>
<!-- 内容 -->
<div class="bd">
<ul>
<li><a href="#">点赞新农人,温暖的伸手</a></li>
<li><a href="#">在希望的田野上</a></li>
<li><a href="#">中国天眼又有新发现</a></li>
<li><a href="#">急,这个领域缺人</a></li>
<li><a href="#">G9带货后,亏损面积持续扩大</a></li>
<li><a href="#">多地方推二手房</a></li>
</ul>
</div>
</div>
</body>
</html>
