-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.html
169 lines (155 loc) · 5.51 KB
/
basic.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>svg basic</title>
<style>
.red {
fill: red;
}
.fancy {
fill: orange;
stroke: green;
stroke-width: 3pt;
}
</style>
</head>
<body style="margin: 0;padding: 0">
<!--circle 圆-->
<div>
<svg width="100%" height="100%">
<circle id="mycircle" cx="50" cy="50" r="50" />
</svg>
</div>
<div>
<svg width="100" height="100" viewBox="50 50 50 50">
<circle id="mycircle" cx="50" cy="50" r="50" />
</svg>
</div>
<div>
<svg width="300" height="180">
<circle cx="50" cy="50" r="25"></circle>
<circle cx="100" cy="50" r="25" class="red"></circle>
<circle cx="150" cy="50" r="25" class="fancy"></circle>
</svg>
</div>
<!--line 线段-->
<div>
<svg width="300" height="180">
<line x1="0" y1="0" x2="200" y2="0" style="stroke: rgb(0,0,0);stroke-width: 5"></line>
</svg>
</div>
<!--ployline 折线-->
<div>
<svg width="300" height="180">
<polyline points="3,3 30,28, 3,53" fill="none" stroke="yellow" stroke-width="3"></polyline>
</svg>
</div>
<!--rect 矩形-->
<svg width="300" height="180">
<rect x="0" y="0" height="100" width="200" style="stroke: #70d5dd; fill: #dd524b"></rect>
</svg>
<!--ellipse 椭圆-->
<svg width="300" height="180">
<ellipse cx="60" cy="60" ry="40" rx="20" stroke="black" stroke-width="5" fill="silver"></ellipse>
</svg>
<!--polygon 多边形-->
<svg width="300" height="180">
<polygon fill="green" stroke="orange" stroke-width="1" points="0,0 100,0 100,100 0,0"></polygon>
</svg>
<!--path 路径-->
<svg width="300" height="180">
<path d="
M 18,3
L 46,3
L 46,40
L 61,40
L 32,68
L 3,40
L 18,40
z
"></path>
</svg>
<div></div>
<!--text 文本-->
<svg width="300" height="180">
<text x="50" y="25">Hello World</text>
</svg>
<!--use 复制-->
<svg viewBox="0 0 30 10" width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<circle id="myCircle" cx="5" cy="5" r="4"></circle>
<use href="#myCircle" x="10" y="0" fill="blue" width="8" height="4"></use>
<use href="#myCircle" x="20" y="0" fill="white" stroke="blue"></use>
</svg>
<!--g group-->
<svg width="300" height="100">
<g id="circle2">
<text x="25" y="20" >circle</text>
<circle cx="50" cy="50" r="20" stroke-width="2"></circle>
</g>
<use href="#circle2" x="100" y="0" fill="blue"></use>
<use href="#circle2" x="200" y="0" fill="white" stroke="blue"></use>
</svg>
<!--defs 引用-->
<svg width="300" height="100">
<defs>
<g id="circle3">
<text x="25" y="20">圆形</text>
<circle cx="50" cy="50" r="20"></circle>
</g>
</defs>
<use href="#circle3" x="0" y="0"></use>
<use href="#circle3" x="100" y="0" fill="blue"></use>
<use href="#circle3" x="200" y="0" fill="white" stroke="blue"></use>
</svg>
<!--pattern 用于平铺-->
<svg width="500" height="500">
<defs>
<pattern id="dots" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse">
<circle fill="#bee9e8" cx="50" cy="50" r="35" />
</pattern>
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="url(#dots)"></rect>
</svg>
<!--image 引用图片-->
<svg viewBox="0 0 50 50" width="100" height="100">
<image xlink:href="./img/eye.png" width="50" height="50"/>
</svg>
<!--animate 动画-->
<svg width="500px" height="500px">
<!--单个属性-->
<rect x="0" y="0" width="100" height="100" fill="#feac5e">
<animate attributeName="x" from="0" to="500" dur="2s" repeatCount="indefinite" />
</rect>
<!--多个属性-->
<rect x="0" y="200" width="100" height="100" fill="green">
<animate attributeName="x" from="0" to="500" dur="2s" repeatCount="indefinite" />
<animate attributeName="width" to="500" dur="2s" repeatCount="indefinite"></animate>
</rect>
</svg>
<!--animateTransform-->
<svg width="500px" height="500px">
<rect x="250" y="250" width="50" height="50" fill="#4bc0c8">
<animateTransform attributeName="transform" type="rotate" begin="0s" dur="10s" from="0 275 275" to="360 275 275" repeatCount="indefinite" />
</rect>
</svg>
<svg width="350" height="160">
<g class="layer" transform="translate(60,10)">
<circle r="5" cx="0" cy="105" />
<circle r="5" cx="90" cy="90" />
<circle r="5" cx="180" cy="60" />
<circle r="5" cx="270" cy="0" />
<g class="y axis">
<line x1="0" y1="0" x2="0" y2="120" stroke-width="1" stroke="black"/>
<text x="-40" y="105" dy="5">$10</text>
<text x="-40" y="0" dy="5">$80</text>
</g>
<g class="x axis" transform="translate(0, 120)">
<line x1="0" y1="0" x2="270" y2="0" stroke-width="1" stroke="black"/>
<text x="-30" y="20">January 2014</text>
<text x="240" y="20">April</text>
</g>
</g>
</svg>
</body>
</html>