码迷,mamicode.com
首页 > 其他好文 > 详细

88svg子标签(示例)

时间:2019-06-03 14:10:37      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:形状   line   水平   str   标签   red   透明度   包含   填充   

母标签<svg>有下列子标签:矩形 <rect>、圆形 <circle>、椭圆 <ellipse>、线 <line>、路径 <path>、 多边形 <polygon>、折线 <polyline>;母子标签之间还可以套进组标签<g></g>、复用标签<defs></defs>;套后标签层级关系为<svg><defs><g><reac></reac><circle></circle>......</g></defs></svg>。
1.矩形 <rect>
x 属性定义矩形的左侧位置(例如,x="0" 定义矩形到浏览器窗口左侧的距离是 0px)
y 属性定义矩形的顶端位置(例如,y="0" 定义矩形到浏览器窗口顶端的距离是 0px)
CSS 的 fill-opacity 属性定义填充颜色透明度(合法的范围是:0 - 1)
CSS 的 stroke-opacity 属性定义笔触颜色的透明度(合法的范围是:0 - 1)

```html:run
<svg width="100%" height="100%">
<rect x="20" y="20" width="250" height="100" style="fill:blue;stroke:pink;stroke-width:5;fill-opacity:0.1;stroke-opacity:0.9"/>
</svg>
```


2.圆形 <circle>
cx 和 cy 属性定义圆点的 x 和 y 坐标。
如果省略 cx 和 cy,圆的中心会被设置为 (0, 0)
r 属性定义圆的半径。
**html 代码**

```html:run
<svg width="100%" height="100%">
<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/>
</svg>
```


3.椭圆 <ellipse>
cx 属性定义圆点的 x 坐标
cy 属性定义圆点的 y 坐标
rx 属性定义水平半径
ry 属性定义垂直半径
**html 代码**

```html:run
<svg width="100%" height="100%">
<ellipse cx="300" cy="150" rx="200" ry="80" style="fill:rgb(200,100,50);stroke:rgb(0,0,100);stroke-width:2"/>
</svg>
```


4.线 <line>
x1 属性在 x 轴定义线条的开始
y1 属性在 y 轴定义线条的开始
x2 属性在 x 轴定义线条的结束
y2 属性在 y 轴定义线条的结束
**html 代码**

```html:run
<svg width="100%" height="100%" >
<line x1="0" y1="0" x2="300" y2="300" style="stroke:rgb(99,99,99);stroke-width:2"/>
</svg>
```


5.路径 <path>
定义了一条路径,它开始于位置 250 150,到达位置 150 350,然后从那里开始到 350 350,最后在 250 150 关闭路径。
**html 代码**

```html:run
<svg width="100%" height="100%">
<path d="M250 150 L150 350 L350 350 Z" />
</svg>
```


6.多边形 <polygon>
points 属性定义多边形每个角的 x 和 y 坐标
**html 代码**

```html:run
<svg width="100%" height="100%">
<polygon points="220,100 300,210 170,250" style="fill:#cccccc; stroke:#000000;stroke-width:1"/>
</svg>
```


7.折线 <polyline>
标签用来创建仅包含直线的形状。

```html:run
<svg width="100%" height="100%">
<polyline points="0,0 0,20 20,20 20,40 40,40 40,60" style="fill:white;stroke:red;stroke-width:2"/>
</svg>
```

88svg子标签(示例)

标签:形状   line   水平   str   标签   red   透明度   包含   填充   

原文地址:https://www.cnblogs.com/gushixianqiancheng/p/10967135.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!