-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfill-stroke.html
52 lines (50 loc) · 2.52 KB
/
fill-stroke.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>填充和边框</title>
</head>
<body>
<!--控制填充以及描边不透明度-->
<svg width="100px" height="100px" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x="10" y="10" width="50" height="50" stroke="blue" stroke-width="3" fill="red" stroke-opacity="0.2" fill-opacity="0.5"></rect>
</svg>
<!--控制线段两端样式 stroke-linecap-->
<!--butt 屁股 square 方形 round 圆角-->
<svg width="160px" height="120px" xmlns="http://www.w3.org/2000/svg" version="1.1">
<line x1="40" x2="120" y1="20" y2="20" stroke="black" t stroke-width="20" stroke-linecap="butt"></line>
<line x1="40" x2="120" y1="60" y2="60" stroke="black" stroke-width="20" stroke-linecap="square"></line>
<line x1="40" x2="120" y1="100" y2="100" stroke="black" stroke-width="20" stroke-linecap="round"></line>
</svg>
<!--控制线段连接方式 stroke-linejoin-->
<!--miter 斜切 bevel 斜角 round 圆-->
<svg width="160" height="280" xmlns="http://www.w3.org/2000/svg" version="1.1">
<polyline points="40 60 80 20 120 60" stroke="blue" stroke-width="20" stroke-linecap="butt" stroke-linejoin="miter" fill="none"></polyline>
<polyline points="40 140 80 100 120 140" stroke="blue" stroke-width="20" stroke-linecap="square" stroke-linejoin="bevel" fill="none"></polyline>
<polyline points="40 220 80 180 120 220" stroke="blue" stroke-width="20" stroke-linecap="round" stroke-linejoin="round" fill="none"></polyline>
</svg>
<!--线段虚线样式 stroke-dasharray-->
<svg width="200" height="150" xmlns="http://www.w3.org/2000/svg" version="1.1">
<path d="M 10 50 Q 55 10 100 50 T 190 50" stroke-linecap="round" stroke-width="2" stroke="black"
fill="none" stroke-dasharray="5,10,5"></path>
<path d="M 10 50 L 190 50 " stroke-linecap="round" stroke="black" stroke-width="2" fill="none" stroke-dasharray="5"></path>
</svg>
<!--svg style-->
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<style>
#myRect {
fill: red;
stroke: green;
stroke-width: 5;
}
#myRect:hover {
fill: green;
stroke: red;
}
</style>
</defs>
<rect x="10" y="10" width="100" height="100" id="myRect"></rect>
</svg>
</body>
</html>