1- <!DOCTYPE html>
2- < html >
3- < head lang ="en ">
4- < meta charset ="UTF-8 ">
5- < title > </ title >
6- < style >
7- div {
8- width : 500px ;
9- height : 100px ;
10- margin : 10px auto;
11- border : 1px solid # 000 ;
12- }
1+ <!doctype html>
2+ < html lang ="en ">
133
14- /* 语法:
15- linear-gradient(方向,起始颜色,终止颜色);
16- 方向:to left to right to top to bottom 角度 30deg
17- 起始颜色
18- 终止颜色
19- */
20- div : nth-child (1 ) {
21- background-image : linear-gradient (to right, yellow, green);
22- }
23-
24- /* 不写方向,表示默认的方向是:从上往下 */
25- div : nth-child (2 ) {
26- background-image : linear-gradient (yellow, green);
27- }
28-
29- /* 方向可以指定角度 */
30- div : nth-child (3 ) {
31- width : 100px ;
32- height : 100px ;
33- background-image : linear-gradient (135deg , yellow, green);
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta name ="Generator " content ="EditPlus® ">
7+ < meta name ="Author " content ="">
8+ < meta name ="Keywords " content ="">
9+ < meta name ="Description " content ="">
10+ < title > Document</ title >
11+
12+ < style type ="text/css ">
13+ .div1 {
14+ width : 0 ;
15+ height : 0 ;
16+ border-top : 30px solid red;
17+ /* 通过改变 border-left 和 border-right 中的像素值,来改变三角形的形状 */
18+ border-left : 30px solid transparent;
19+ border-right : 20px solid transparent;
3420 }
3521
36- /* 0%的位置开始出现黄色,40%的位置开始出现红色的过度。70%的位置开始出现绿色的过度,100%的位置开始出现蓝色 */
37- div : nth-child (4 ) {
38- background-image : linear-gradient (to right,
39- yellow 0% ,
40- red 40% ,
41- green 70% ,
42- blue 100% );
43-
22+ .box2 {
23+ width : 250px ;
24+ height : 250px ;
25+ padding : 25px ;
26+ border : 1px solid red;
4427 }
28+ </ style >
4529
46- /* 颜色之间,出现突变 */
47- div : nth-child (5 ) {
48- background-image : linear-gradient (45deg ,
49- yellow 0% ,
50- yellow 25% ,
51- blue 25% ,
52- blue 50% ,
53- red 50% ,
54- red 75% ,
55- green 75% ,
56- green 100%
57- );
58- }
30+ </ head >
5931
60- div : nth-child (6 ) {
61- background-image : linear-gradient (to right,
62- # 000 0% ,
63- # 000 25% ,
64- # fff 25% ,
65- # fff 50% ,
66- # 000 50% ,
67- # 000 75% ,
68- # fff 75% ,
69- # fff 100%
70- );
32+ < body >
7133
72- }
34+ < div class ="div1 "> </ div >
35+ < div class ="box2 "> 狭路相逢</ div >
7336
74- </ style >
75- </ head >
76- < body >
77- < div > </ div >
78- < div > </ div >
79- < div > </ div >
80- < div > </ div >
81- < div > </ div >
82- < div > </ div >
8337</ body >
38+
8439</ html >
0 commit comments