SVG实例

SVG元素

SVG各种类型的例子

 

Demo1:渐变文字

代码:

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Applying a gradient background to text in SVG</title>
 </head>
 <body>
    <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1200 400"> 
        <defs>
            <linearGradient id = "filler" x = "0%" y = "100%">
                <stop stop-color = "olivedrab" offset = "0%"/>
                <stop stop-color = "peru" offset = "20%"/>
                <stop stop-color = "goldenrod" offset = "40%"/>
                <stop stop-color = "firebrick" offset = "60%"/>
                <stop stop-color = "thistle" offset = "80%"/>
                <stop stop-color = "sandybrown" offset = "100%"/>
            </linearGradient>
        </defs>
        <text x="0" y="70%" font-size="180" fill="url(#filler)">S.QW.YA</text>
    </svg>
 </body>
</html>

 效果:

解释:

xmlns="http://www.w3.org/2000/svg"      是XML命名空间,在SVG标签中定义 。

version="1.1"      是SVG命名空间的版本。

viewBox     属性允许指定一个给定的一组图形伸展以适应特定的容器元素。

<svg>

<defs>     引用的元素容器

<linearGradient>

<stop>

<text>

 

demo2:折线

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>My svg demo</title>
 </head>
 <body>
        <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
            <polyline points="20,20 40,25 60,40 80,120 120,140 200,180" style="fill:none;stroke:black;stroke-width:3" />
        </svg>
 </body>
</html>

 效果:

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值