前言:

本文内容:背景图应用及渐变、盒子模型及边框使用

推荐免费CSS3基础讲解视频:【狂神说Java】CSS3最新教程快速入门通俗易懂_哔哩哔哩_bilibili

背景图片应用及渐变

背景图片

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<style>
div{
width: 700px;
height: 500px;
border: 1px solid black;
/*图片默认是平铺的*/
background-image: url("image/images.png");

}
.div1{
/*水平平铺*/
background-repeat: repeat-x;
}
.div2,.div3{
/*水平平铺*/
background-repeat: no-repeat;
}

</style>

列表样式美化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#nav{
width: 300px;
}
h1{
color: red;
/*颜色 图片 图片位置 平铺方式*/
background: url("../image/down.jpg") 230px 15px no-repeat;
}
/*ul li*/
/*
list-style
none 无
circle 空心圆
decimal 数字
square 正方形
armenian 默认 实心圆
*/
ul li{
height: 30px;
list-style: none;
background: url("../image/up.jpg");
background-repeat: no-repeat;
background-position: 230px,2px;

}
a{
text-decoration: none;
font-size: 14px;
color: black;
}

a:hover{
background: #b8b5b5;
color: #e71111;
}

颜色渐变

Grabient

GitHub - johnkorzhuk/grabient: UI to generate linear-gradients

1
2
3
4
5
6
7
8
9
<style>
body{
background-color: #8EC5FC;
background-image: -webkit-linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%);
background-image: -moz-linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%);
background-image: -o-linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%);
background-image: linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%);
}
</style>

153

盒子模型及边框使用

什么是盒子模型

152

margin:外边距

padding:内边距

border:边框

边框

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
/*去除默认边距及超链接下划线*/
*{
margin: 0;
padding: 0;
text-decoration: none;
}
/*border: 粗细 样式 颜色*/
#box{
width: 300px;
border: 1px solid red;
}
h2,form{
background-color: #D9AFD9;
background-image: -webkit-linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%);
background-image: -moz-linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%);
background-image: -o-linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%);
background-image: linear-gradient(344deg, #D9AFD9 0%, #97D9E1 100%);
}
/*solid 实线*/
div:nth-of-type(1) input{
border: 2px solid black;
}
/*dashen 虚线*/
div:nth-of-type(2) input{
border: 2px dashed black;
}
</style>
</head>
<body>
<div id="box">
<h2>会员登录</h2>
<form action="#">
<div>
<span>账号:</span>
<input type="text">
</div>
<div>
<span>密码:</span>
<input type="password">
</div>
<div>
<span>邮箱:</span>
<input type="email">
</div>
<div>
<input type="submit" value="登录"/>
<input type="reset" value="取消"/>
</div>
</form>
</div>
</body>
</html>

151