前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SVG绘制渐变对象

SVG绘制渐变对象

作者头像
越陌度阡
发布2020-11-26 15:01:42
4340
发布2020-11-26 15:01:42
举报

运用SVG实现一个渐变对象效果。

实现效果如下:

实现代码如下:

代码语言:javascript
复制
<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>SVG绘图渐变对象</title>
    <style>
        body {
            text-align: center;
        }

        svg {
            background: #ddd;
        }
    </style>
</head>

<body>
    <h1>SVG绘图渐变对象</h1>
    <svg id="s9" width="500" height="400">
        <defs>
            <linearGradient id="g0" x1="0" y1="0" x2="0" y2="100%">
                <stop offset="0" stop-color="red"></stop>
                <stop offset="1" stop-color="red" stop-opacity="0"></stop>
            </linearGradient>

            <linearGradient id="g1" x1="0" y1="0" x2="0" y2="100%">
                <stop offset="0" stop-color="green"></stop>
                <stop offset="1" stop-color="green" stop-opacity="0"></stop>
            </linearGradient>

            <linearGradient id="g2" x1="0" y1="0" x2="0" y2="100%">
                <stop offset="0" stop-color="blue"></stop>
                <stop offset="1" stop-color="blue" stop-opacity="0"></stop>
            </linearGradient>
        </defs>
        <rect width="50" height="100" x="100" y="50" fill="url(#g0)"></rect>
        <rect width="50" height="300" x="200" y="50" fill="url(#g1)"></rect>
        <rect width="50" height="200" x="300" y="50" fill="url(#g2)"></rect>
    </svg>
</body>

</html>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/06/30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档