Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:字体图标, vscode中的有一些插件,可以直接预览的, 可以关注一下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>渐变色</title>
<style>
.box {
width: 500px;
height: 500px;
padding: 30px;
/* background: red; */
border: red 1px dashed;
/* 渐变色 */
/* background: linear-gradient(red, pink); */
/* 渐变色 设置渐变角度45度*/
/* background: linear-gradient(45deg, red, pink); */
/* 渐变色 从左到右 to right 右到左 to left*/
background: linear-gradient(to left, red, pink);
/* 可以多种颜色 */
background: linear-gradient(
to right,
red,
pink,
#666,
#954,
rgba(255, 0, 0, 0.1)
);
/* 裁切掉padding中的颜色 */
background-clip: content-box;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
背景属性用于定义HTML元素的背景,通常用以下常用属性来控制背景效果
当使用简写属性时,属性值的顺序为::
background-color
background-image
background-repeat
background-attachment
background-position
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>02背景图</title>
<style>
.box {
width: 500px;
height: 500px;
border: dashed 1px red;
/* 图片默认是平铺的 */
background-image: url("images/girl.jpg");
/* 禁止平铺只显示一个图 */
/* 背景-重复:关-重复 */
background-repeat: no-repeat;
/* 只朝一个方向重复 横向重复repeat-x 纵向重复 */
/* background-repeat: repeat-y; */
/* 背景的定位 position是位置的意思*/
background-position: 20px 20px;
background-position: left;
background-position: right center;
background-position: 30% 80%;
/* 设置图片的铺设大小 size大小 contain包含-拉伸满*/
background-size: contain;
/* 拉伸 */
background-size: cover;
/* box-shadow: 5px 8px 6px indianred; */
}
.box:hover {
/* 设置悬停鼠标手 */
cursor: pointer;
}
.box2 {
/* 设置边框投影 */
height: 500px;
width: 500px;
background-color: rgb(255, 0, 0);
/* 水平偏移 垂直偏移 扩散阴影 颜色 */
box-shadow: 15px 20px 20px indianred;
/* 设置圆角 */
border-radius: 350px;
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box2"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>03.实战精灵图</title>
<style>
.box1 {
width: 300px;
height: 300px;
background-image: url("./images/jl.png");
/* 背景图是否重负 禁止重复no-repeat; */
background-repeat: no-repeat;
/* background-image: url(images/jl.png); */
border: 1px dashed red;
}
.box2 {
width: 25px;
height: 25px;
background-image: url("./images/jl.png");
background-repeat: no-repeat;
/* 定位精灵图片位置 */
background-position: -50px -50px;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
1.首先登陆https://www.iconfont.cn/
2.下载阿里图标
3.Font class 的方式编写代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>阿里字体的引用-Font class</title>
<link rel="stylesheet" href="./font/font_tkizmt6c4ur/iconfont.css" />
<style>
.spa1 {
font-size: 60px;
color: red;
box-shadow: 5px 5px 5px #000;
}
</style>
</head>
<body>
<span class="iconfont icon-icon-test26 spa1"></span>
</body>
</html>
4.Unicode的方式编写代码
@font-face {
font-family: "iconfont";
src: url("./font/font_tkizmt6c4ur/iconfont.eot");
src: url("./font/font_tkizmt6c4ur/iconfont.eot?#iefix")
format("embedded-opentype"),
url("./font/font_tkizmt6c4ur/iconfont.woff2") format("woff2"),
url("./font/font_tkizmt6c4ur/iconfont.woff") format("woff"),
url("./font/font_tkizmt6c4ur/iconfont.ttf") format("truetype"),
url("./font/font_tkizmt6c4ur/iconfont.svg#iconfont") format("svg");
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>阿里字体的引用-Font class</title>
<link rel="stylesheet" href="style.css" />
<style>
.span1 {
font-size: 60px;
color: red;
box-shadow: 5px 5px 5px #000;
}
</style>
</head>
<body>
<span class="iconfont span1"></span>
</body>
</html>