css如何改变svg颜色


本文摘自PHP中文网,作者醉折花枝作酒筹,侵删。

在css中,可以使用stroke属性改变svg颜色,只需要给svg中的polyline标签设置“stroke:颜色值”样式即可。stroke属性定义一条线,文本或元素轮廓颜色,值和color一样,支持rgba透明通道。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

有些时候我们也许会使用css直接操控svg,svg可以像jpg,png那样以图片形式使用,也可以直接以标签形式使用。前者不可以设置颜色,而后者可以。

示例:

1

2

3

4

5

6

7

8

9

<svg width="8px" height="12px" viewBox="0 0 8 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

    <!-- Generator: Sketch 47.1 (45422) - http://www.bohemiancoding.com/sketch -->

    <title>Rectangle 8 Copy 10</title>

    <desc>Created with Sketch.</desc>

    <defs></defs>

    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">

        <polyline id="Rectangle-8-Copy-10" stroke="#8F99AE" stroke-width="2" transform="translate(2.242641, 6.242641) scale(1, -1) rotate(-135.000000) translate(-2.242641, -6.242641) " points="5.24264069 9.24264069 -0.757359313 9.24264069 -0.757359313 3.24264069 -0.757359313 3.24264069"></polyline>

    </g>

</svg>

效果:

阅读剩余部分

相关阅读 >>

如何实现炫酷的数字大屏

style标签怎么用?

css如何设置边框透明

css盒子中的图如何居中

css 内阴影怎么做

网页设计是要学 php 还是 java

css实现将网页变成黑白色

css样式“list-style:none”是什么意思?

background-image属性怎么用

css counter-reset属性怎么用

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...