一、矩形 < rect >
- x
- y
- width
- height
- rx
- ry
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/aa2da769a5332a62af99a5aa868f9828.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#svg-wrap {
width: 500px;
height: 500px;
border: 1px solid #008000;
}
</style>
</head>
<body>
<svg id="svg-wrap" xmlns="http://www.w3.org/2000/svg">
<rect x='100' y="100" width="100" height="100" fill="pink" stroke='#008000'>
</rect>
<rect x='300' y="300" width="100" height="100" style="fill: skyblue;" rx='10' ry='20'></rect>
</svg>
</body>
</html>
二、圆形 < circle >
- cx
- cy
- r
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/51f6b7c367d7d4c670a10a01ca446a4d.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#svg-wrap {
width: 500px;
height: 500px;
border: 1px solid #008000;
}
</style>
</head>
<body>
<svg id="svg-wrap" xmlns="http://www.w3.org/2000/svg">
<circle cx='100' cy='100' r='60' style='fill: #FF6600;'></circle>
<circle cx='100' cy='100' r='40' style='fill: #FFFF00;'></circle>
</svg>
</body>
</html>
三、椭圆 < ellipse >
- cx
- cy
- rx
- ry
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e8b0bf471e3b854a1e6f6ab7498ca27a.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#svg-wrap {
width: 500px;
height: 500px;
border: 1px solid #008000;
}
</style>
</head>
<body>
<svg id="svg-wrap" xmlns="http://www.w3.org/2000/svg">
<ellipse cx='100' cy='100' rx='60' ry='30' style='fill: #FF6600;'></ellipse>
</svg>
</body>
</html>
四、线 < line >
- x1
- y1
- x2
- y2
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/15910808cb08c9478395029971d8b3a6.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#svg-wrap {
width: 500px;
height: 500px;
border: 1px solid #008000;
}
</style>
</head>
<body>
<svg id="svg-wrap" xmlns="http://www.w3.org/2000/svg">
<line x1='5' y1='5' x2='100' y2='100' style='stroke: red; stroke-width: 2;'></line>
<line x1='150' y1='150' x2='300' y2='300' style='stroke: red; stroke-width: 2;'></line>
</svg>
</body>
</html>
五、折线 < polyline >
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/890bbde42e1c641cbc7b9f459ba03c2c.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#svg-wrap {
width: 500px;
height: 500px;
border: 1px solid #008000;
}
</style>
</head>
<body>
<svg id="svg-wrap" xmlns="http://www.w3.org/2000/svg">
<polyline points='20,20,40,25,60,40,80,120,120,140,200,180' stroke='red' fill='none'>
</polyline>
</svg>
</body>
</html>
六、多边形< polygon >
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c97be2208a5f19ad90f23f24b8c63982.png)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#svg-wrap {
width: 500px;
height: 500px;
border: 1px solid #008000;
}
</style>
</head>
<body>
<svg id="svg-wrap" xmlns="http://www.w3.org/2000/svg">
<polygon points='200,10,250,190,160,120' stroke='red' fill='none'>
</polygon>
</svg>
</body>
</html>
七、填充、描边、变换
- fill
- stroke
- stroke-width
- transform
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/16df22ccbd39ab5fedc484a78481835f.png)
制作整理不易,以上内容均为原创(参考了部分官方文档和老师整理的案例)。如要引用请附上本文链接,如有疑问可以在评论区畅所欲言,作者看到会第一时间回复,欢迎交流!