结构伪类-图形-字体-字体图标-元素定位
结构性伪类选择器
nth-child
- 父元素中的第n个子元素
nth-child(n)
<!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>Document</title>
<style>
ul li:nth-child(1) {
color: #f00;
}
ul li:nth-child(3) {
color: #f00;
}
</style>
</head>
<body>
<ul>
<li>列表元素1</li>
<li>列表元素2</li>
<li>列表元素3</li>
<li>列表元素4</li>
<li>列表元素5</li>
<li>列表元素6</li>
</ul>
</body>
</html>
nth-child(几n + 几)
<!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>Document</title>
<style>
ul li:nth-child(2n) {
color: #0f0;
}
ul li:nth-child(2n + 1) {
color: blue;
}
div > div:nth-child(4n + 1) {
color: orange;
}
div > div:nth-child(4n + 2) {
color: purple;
}
div > div:nth-child(4n + 3) {
color: red;
}
div > div:nth-child(4n + 4) {
color: green;
}
</style>
</head>
<body>
<ul>
<li>列表元素1</li>
<li>列表元素2</li>
<li>列表元素3</li>
<li>列表元素4</li>
<li>列表元素5</li>
<li>列表元素6</li>
</ul>
<div>
<div>列表元素1</div>
<div>列表元素2</div>
<div>列表元素3</div>
<div>列表元素4</div>
<div>列表元素5</div>
<div>列表元素6</div>
<div>列表元素7</div>
<div>列表元素8</div>
<div>列表元素9</div>
<div>列表元素10</div>
</div>
</body>
</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>Document</title>
<style>
ul li:nth-child(2n) {
color: #0f0;
}
ul li:nth-child(2n + 1) {
color: blue;
}
div > div:nth-child(4n + 1) {
color: orange;
}
div > div:nth-child(4n + 2) {
color: purple;
}
div > div:nth-child(4n + 3) {
color: red;
}
div > div:nth-child(4n + 4) {
color: green;
}
div > div:nth-child(-n + 5) {
font-size: 25px;
}
</style>
</head>
<body>
<ul>
<li>列表元素1</li>
<li>列表元素2</li>
<li>列表元素3</li>
<li>列表元素4</li>
<li>列表元素5</li>
<li>列表元素6</li>
</ul>
<div>
<div>列表元素1</div>
<div>列表元素2</div>
<div>列表元素3</div>
<div>列表元素4</div>
<div>列表元素5</div>
<div>列表元素6</div>
<div>列表元素7</div>
<div>列表元素8</div>
<div>列表元素9</div>
<div>列表元素10</div>
</div>
</body>
</html>
- 偶 even
- 奇数 odd
nth-last-child
<!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>Document</title>
<style>
ul > li:nth-child(2) {
color: red;
}
ul > li:nth-last-child(2) {
color: red;
}
ul > li:nth-last-child(-n + 3) {
font-size: 20px;
}
</style>
</head>
<body>
<ul>
<li>列表元素1</li>
<li>列表元素2</li>
<li>列表元素3</li>
<li>列表元素4</li>
<li>列表元素5</li>
<li>列表元素6</li>
<li>列表元素7</li>
<li>列表元素8</li>
</ul>
</body>
</html>
nth-of-type
<!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>Document</title>
<style>
.box div:nth-child(3) {
color: red;
}
.box div:nth-of-type(3) {
color: blue;
}
</style>
</head>
<body>
<div class="box">
<div>我是列表1</div>
<p>我是p元素捣乱的</p>
<div>我是列表2</div>
<div>我是列表3</div>
<div>我是列表4</div>
<div>我是列表5</div>
<div>我是列表6</div>
<div>我是列表7</div>
<div>我是列表8</div>
<div>我是列表9</div>
<div>我是列表10</div>
</div>
</body>
</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>Document</title>
<style>
.box div:nth-child(3) {
color: red;
}
.box div:nth-child(9) {
color: red;
}
.box div:nth-of-type(3) {
color: blue;
}
</style>
</head>
<body>
<div class="box">
<div>我是列表1</div>
<p>我是p元素捣乱的</p>
<span>我是span1</span>
<span>我是span2</span>
<span>我是span3</span>
<div>我是列表2</div>
<div>我是列表3</div>
<div>我是列表4</div>
<div>我是列表5</div>
<div>我是列表6</div>
<div>我是列表7</div>
<div>我是列表8</div>
<div>我是列表9</div>
<div>我是列表10</div>
</div>
</body>
</html>
nth-last-of-type
first-child
<!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>Document</title>
<style>
.box > div:first-child {
color: red;
}
</style>
</head>
<body>
<div class="box">
<div>列表内容1</div>
<div>列表内容2</div>
<div>列表内容3</div>
<div>列表内容4</div>
<div>列表内容5</div>
</div>
</body>
</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>Document</title>
<style>
.box > :first-child {
color: red;
}
</style>
</head>
<body>
<div class="box">
<span>span元素</span>
<div>列表内容1</div>
<div>列表内容2</div>
<div>列表内容3</div>
<div>列表内容4</div>
<div>列表内容5</div>
</div>
</body>
</html>
last-child
first-of-type
last-of-type
only-child
<!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>Document</title>
<style>
.box > :first-child {
color: red;
}
.boxs div:only-child {
color: green;
}
.boxes div:only-child {
color: green;
}
.boxss div:only-of-type {
color: blue;
}
</style>
</head>
<body>
<div class="box">
<span>span元素</span>
<div>列表内容1</div>
<div>列表内容2</div>
<div>列表内容3</div>
<div>列表内容4</div>
<div>列表内容5</div>
</div>
<div class="boxs">
<div>我是box的div</div>
</div>
<div class="boxes">
<div>我是box的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
<div class="boxss">
<div>我是container的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
</body>
</html>
only-of-type
<!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>Document</title>
<style>
.box > :first-child {
color: red;
}
.boxs div:only-child {
color: green;
}
.boxes div:only-child {
color: green;
}
.boxss div:only-of-type {
color: blue;
}
</style>
</head>
<body>
<div class="box">
<span>span元素</span>
<div>列表内容1</div>
<div>列表内容2</div>
<div>列表内容3</div>
<div>列表内容4</div>
<div>列表内容5</div>
</div>
<div class="boxs">
<div>我是box的div</div>
</div>
<div class="boxes">
<div>我是box的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
<div class="boxss">
<div>我是container的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
</body>
</html>
root
<!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>Document</title>
<style>
.box > :first-child {
color: red;
}
.boxs div:only-child {
color: green;
}
.boxes div:only-child {
color: green;
}
.boxss div:only-of-type {
color: blue;
}
:root {
font-size: 30px;
}
</style>
</head>
<body>
<div class="box">
<span>span元素</span>
<div>列表内容1</div>
<div>列表内容2</div>
<div>列表内容3</div>
<div>列表内容4</div>
<div>列表内容5</div>
</div>
<div class="boxs">
<div>我是box的div</div>
</div>
<div class="boxes">
<div>我是box的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
<div class="boxss">
<div>我是container的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
</body>
</html>
empty
<!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>Document</title>
<style>
.box > :first-child {
color: red;
}
.boxs div:only-child {
color: green;
}
.boxes div:only-child {
color: green;
}
.boxss div:only-of-type {
color: blue;
}
:root {
font-size: 30px;
}
:empty {
width: 100px;
height: 100px;
background-color: #f00;
}
</style>
</head>
<body>
<div class="box">
<span>span元素</span>
<div>列表内容1</div>
<div>列表内容2</div>
<div>列表内容3</div>
<div>列表内容4</div>
<div>列表内容5</div>
</div>
<div class="boxs">
<div>我是box的div</div>
</div>
<div class="boxes">
<div>我是box的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
<div class="boxss">
<div>我是container的div</div>
<p>p元素</p>
<p>p元素</p>
</div>
<div></div>
</body>
</html>
not
<!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>Document</title>
<style>
div > .item {
color: red;
}
div > :not(.item) {
font-weight: 700;
}
</style>
</head>
<body>
<div>
<div class="item">列表内容1</div>
<div class="item">列表内容2</div>
<div class="why">列表内容3</div>
<div class="item">列表内容4</div>
<div class="item">列表内容5</div>
</div>
</body>
</html>
border边框
<!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>Document</title>
<style>
.box {
width: 100px;
height: 100px;
/* background-color: #f00; */
box-sizing: border-box;
border: 50px solid orange;
/* border-right-color: blue;
border-bottom-color: aqua;
border-left-color: purple; */
border-right-color: transparent;
border-bottom-color: transparent;
border-left-color: transparent;
transform: rotate(180deg);
transform-origin: 50% 25%;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</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>Document</title>
<style>
.box {
width: 100px;
height: 100px;
box-sizing: border-box;
border: 50px solid transparent;
border-top-color: orange;
transform: rotate(180deg);
transform-origin: 50% 25%;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</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>Document</title>
<style>
/* 将这个字体引入到网页中 */
@font-face {
font-family: "AaQingHuanYuanTi";
src: url("./fonts/AaQingHuanYuanTi-2.ttf");
}
.box {
font-size: 20px;
font-family: "AaQingHuanYuanTi";
}
</style>
</head>
<body>
<div>我是div元素</div>
<div class="box">我是div元素</div>
</body>
</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>Document</title>
<style>
@font-face {
font-family: "AaQingHuanYuanTi";
src: url("./fonts02/AaQingHuanYuanTi.eot"); /* IE9 */
src: url("./fonts02/AaQingHuanYuanTi.eot?#iefix")
format("embedded-opentype"),
/* IE6-IE8 */ url("./fonts02/AaQingHuanYuanTi.woff") format("woff"),
/* chrome、firefox */ url("./fonts02/AaQingHuanYuanTi.ttf")
format("truetype"),
/* chrome、firefox、opera、Safari, Android, iOS 4.2+ */
url("./fonts02/AaQingHuanYuanTi.svg#uxfonteditor") format("svg"); /* iOS 4.1- */
font-style: normal;
font-weight: 400;
}
.box {
font-family: "AaQingHuanYuanTi";
}
</style>
</head>
<body>
<div>我是div元素</div>
<div class="box">我是div元素</div>
</body>
</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>Document</title>
<style>
@font-face {
font-family: "iconfont";
src: url("./fonts3/iconfont.ttf");
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.music::before {
content: "\e664";
}
.icon {
width: 20px;
height: 20px;
display: inline-block;
}
</style>
</head>
<body>
<i class="iconfont"></i>
<i class="iconfont"></i>
<i class="icon"></i>
<i class="iconfont music"></i>
</body>
</html>
字体图标的使用步骤
- 通过link引入iconfont.css文件
- 使用字体图标
使用字体图标常见的两种方式
- 通过对应字体图标的Unicode来显示代码
- 利用已经编写好的class,直接使用既可
<!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>Document</title>
<link rel="stylesheet" href="./fonts3/iconfont.css" />
<style>
.icon-shouye {
font-size: 30px;
color: red;
}
</style>
</head>
<body>
<i class="iconfont icon-shouye"></i>
</body>
</html>
精灵图
什么是精灵图
- 是一种css图像合成技术,将各种小图片合并到一张图片上,然后利用css的背景定位来显示对应的图片部分
- 有人翻译为 css雪碧 css精灵
使用css精灵图的好处
- 减少网页的http请求数量,加快网页响应速度,减轻服务器压力
- 减少图片总大小
- 解决了图片命名的困扰,只需要针对一张集合的图片命名
http://www.spritecow.com/
<!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>Document</title>
<style>
.box {
background-color: #333;
}
i.topbar {
display: inline-block;
background-image: url(./images/topbar_sprite.png);
background-repeat: no-repeat;
}
i.hot-icon {
width: 26px;
height: 13px;
background-position: -192px 0;
}
i.logo-icon {
width: 157px;
height: 33px;
background-position: 0 -19px;
}
</style>
</head>
<body>
<div class="box">
<i class="topbar hot-icon"></i>
<i class="topbar logo-icon"></i>
</div>
</body>
</html>
cursor
- 鼠标样式
- auto
- default
- pointer
- text
- none
<!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>Document</title>
<style>
div {
/* cursor: auto; */
cursor: pointer;
text-decoration: underline;
color: #00f;
}
a {
cursor: auto;
}
</style>
</head>
<body>
<div>我是box</div>
<a href="http://www.baidu.com">百度一下</a>
</body>
</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>Document</title>
<style>
.box {
display: inline-block;
}
</style>
</head>
<body>
<div>div元素</div>
<span>span元素</span>
<img src="./images/gouwujie01.jpg" alt="" />
<div class="box"></div>
</body>
</html>
static
- 默认值 静态定位
- left/right/bottom/top 无效
<!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>Document</title>
<style>
.box {
display: inline-block;
/* 默认值 静态定位 */
position: static;
}
</style>
</head>
<body>
<div>div元素</div>
<span>span元素</span>
<img src="./images/gouwujie01.jpg" alt="" />
<div class="box"></div>
</body>
</html>
relative
- 相对定位
- left/right/top/bottom 有效
- 定位参照对象是元素自己原来的位置
<!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>Document</title>
<style>
.text {
position: relative;
/* top: 50px; */
/* left: 30px; */
/* bottom: 50px;
right: 30px; */
top: -50px;
left: -30px;
}
</style>
</head>
<body>
<span>我是span元素</span>
<strong class="text">我是strong元素</strong>
<img src="./images/kobe01.jpg" alt="" />
<div>我是div元素</div>
</body>
</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>Document</title>
<style>
div {
font-size: 20px;
}
span {
font-size: 12px;
position: relative;
top: -8px;
}
</style>
</head>
<body>
<div>3<span>2</span>+2<span>3</span> = 17</div>
</body>
</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>Document</title>
<style>
body {
padding: 0;
margin: 0;
}
.box {
height: 489px;
background-color: #f00;
overflow: hidden;
}
.box img {
position: relative;
left: -960px;
margin-left: 50%;
}
</style>
</head>
<body>
<div class="box">
<img src="./images/mhxy.jpg" alt="" />
</div>
</body>
</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>Document</title>
<style>
body {
padding: 0;
margin: 0;
}
.box {
height: 489px;
background-color: #f00;
overflow: hidden;
}
.box img {
position: relative;
transform: translate(-50%);
margin-left: 50%;
}
</style>
</head>
<body>
<div class="box">
<img src="./images/mhxy.jpg" alt="" />
</div>
</body>
</html>
absolute
- 绝对定位
fixed
- 固定定位
- top/right/bottom/left 有效
- 定位参考对象是视口 (viewport)
<!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>Document</title>
<style>
.text {
position: fixed;
/* left: 0;
top: 0; */
bottom: 30px;
right: 30px;
}
</style>
</head>
<body>
<span>我是span元素</span>
<strong class="text">我是strong元素</strong>
<img src="./images/kobe01.jpg" alt="" />
<div>我是div元素</div>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</body>
</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>Document</title>
<style>
.handle {
position: fixed;
right: 30px;
bottom: 30px;
}
.handle .item {
width: 80px;
height: 40px;
text-align: center;
line-height: 40px;
background-color: brown;
color: #fff;
border-radius: 8px;
cursor: pointer;
}
.handle .item:hover {
background-color: red;
}
.top {
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="handle">
<div class="item top">顶部</div>
<div class="item bottom">反馈</div>
</div>
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
</body>
</html>
sticky
- 粘性定位
内容回顾
一、结构伪类
1.1.nth-child
- nth-child(2)
- nth-child(2n + 1)
- nth-child(-n + 5)
1.2.
- nth-last-child
- nth-of-type
- nth-last-of-type
1.3.其他结构伪类
- first-child
- root
- html
- empty
1.4.否定伪类
- not()
二、额外知识补充
2.1.border的图形
- 三角形
- 旋转
2.2.网络字体
2.3.字体图标
- 选择图标
- 下载代码
- 在项目中使用
2.4.css sprite
- 将多个图标放到一张图片
- 使用图片
-
- width
- height
- background-position
三、元素定位
3.1.对标准流的理解
3.2.元素的定位
常见的值
- static
- relative
- absolute
- fixed
- sticky
3.3.相对定位
- relative
- 相对于自己原来的位置(标准流中的位置)
- left/right/top/bottom
- 小案例
- 3 + 2 = 5
- img居中显示
3.4.固定定位
- fixed
- 相对视口
- 不会随着内容的滚动而滚动
- 练习
- 建议/反馈案例
课后作业
一. 完成课堂所有的代码
二. 说出结构伪类的nth-child和nth-of-type的区别,并且写出案例练习
三. 自己练习使用字体图标
- 从iconfont中下载图标练习