svg阴影 和渐变

 两个基本的标签   用id来区分

feoffset  偏移图片 用于创建 阴影 

feBlend         可以将偏移的图片进行显示

filter  过滤器

定义滤镜:

<defs>

filter   使用偏移滤镜  feoffset 

<defs>

 in 属性的取值:SourceGraphic

 偏移:矩形

进行模糊处理

feGaussianBlur

控制滤镜的颜色

fecolorMatrix 

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
    <svg>
			<!-- 定义滤镜 -->
			<defs>
				<!-- width="200%" 绘制滤镜框的宽度 -->
				<filter id="f1" width="200%" height="200%">
					<!-- 使用偏移滤镜 -->
					<feOffset in="SourceGraphic" result="offset1" dx="20" dy="20"></feOffset>
					<!-- 模糊的颜色 -->
					<feColorMatrix in="offset1" result="colorMatrix" type="matrix" values="0.2 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 10 0"></feColorMatrix>
					<!-- 进行模糊处理 -->
					<feGaussianBlur result="blur" in="colorMatrix" stdDeviation="10"></feGaussianBlur>
					<!-- 使用混合滤镜,主要将原始标签显示出来 -->
					<!-- mode="normal" mode="bmultiply" -->
					<feBlend in="SourceGraphic" in2="color" mode="normal"></feBlend>	
					<feBlend></feBlend>
				</filter>
			</defs>
			<rect x="0" y="0" width="200" height="100" fill="red" stroke="black" filter="url(#f1)"></rect>
		</svg>
</body>

</html>

svg 渐变

linearGraddien:

id  索引值

x1 y1 开始  (用百分比表示)

x2 y2 结束

stop 设置渐变色 offset=“100%”(代表设置区域的100%) 偏移 stop-color 设置的颜色

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <svg>
        <!-- 定义一个渐变 -->
        <defs>
            <linearGradient id="linear" x1="0%" y1="0%"
            x2="100%" y2="0%">
            <!-- 设置渐变色,使用stop标签 -->
                <stop offset="10%" stop-color="red"></stop>
                <stop offset="90%" stop-color="yellow"></stop>
            </linearGradient>
        </defs>
        <rect x="0" y="0" width="200" height="500" fill="url(#linear)" stroke="green"></rect>
    </svg>
</body>

</html>

 <rect x="0" y="0" width="200" height="100" fill="url(#linear)" stroke="red"></rect>

记得加载体

径向渐变

radialGradient

 cx,cy  渐变的中心点

r  渐变的半径

fx ,fy  渐变的焦点x轴

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <svg>
        <defs>
            
            <!-- 矩形中心的圆渐变 -->
            <radialGradient id="radial" cx="50%" cy="50%" r="30%" fx="50%" fy="50%">
                <stop offset="20%" stop-color="red">

                </stop>
                <stop offset="70%" stop-color="yellow">

                </stop>
            </radialGradient>
        </defs>
        <rect x="0" y="0" width="200" height="100" fill="url(#radial)" stroke="red"></rect>
    </svg>
</body>

</html>

 <rect x="0" y="0" width="200" height="100" fill="url(#radial)" stroke="red"></rect>

记得加载体

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值