您的位置:首页 > Web前端 > HTML5

用SVG绘制各种基本形状

2018-01-28 17:16 369 查看
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
* {
margin: 0;
padding: 0;
}

svg {
border: 1px solid #ff0000;
box-sizing: border-box;
}
</style>
<title>Document</title>
</head>
<body>
<svg width="800" height="400">
<rect x="10" y="10" rx="10" ry="10" width="50" height="20" stroke="#f00" fill="transparent"></rect>
<circle cx="100" cy="40" r="30" stroke="red" fill="transparent"></circle>
<ellipse cx="300" cy="60" rx="100" ry="50" stroke="red" fill="transparent"></ellipse>
<line x1="450" y1="10" x2="550" y2="50" stroke="red"></line>
<polyline points="10 200, 200 200, 250 300, 200 350, 10 350, 10 200" stroke="red" fill="transparent"></polyline>
<polygon points="10 200, 200 200, 250 300, 200 350, 10 350" stroke="red" fill="transparent" transform="translate(300)"></polygon>
</svg>
</body>
</html>
 以上分别为矩形/圆形/椭圆/线段/折线/多边形
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  svg html5