效果图如下:
就像是一圈圈蚂蚁在它身上爬。。。。。emmmmm奇特的比喻
fill:none;可以让图形不被填充,如果不添加这一属性,则默认填充颜色是black,这个效果
发现stroke这一系列属性都很有意思啊,填充啊透明度和stroke-linecap,但是这个效果用的最多的还是stroke-dasharray和stroke-dashoffset。
stroke-miterlimit 表示描边相交(锐角)的表现方式。默认大小是4. 什么斜角转斜面的角度损耗之类的意思,值越大,损耗越小。具体干嘛的,我自己也不确定。大家可查查其他资料。
stroke-dasharray 表示虚线描边。可选值为:none,
stroke-dashoffset 表示虚线的起始偏移。可选值为:
stroke-opacity 表示描边透明度。默认是1.
特别佩服作者列举的一个生动形象的例子:
一根火腿肠12厘米,要在上面画虚线,虚线间隔有15厘米,如果没有dashoffset,则火腿肠前面15厘米会被辣椒酱覆盖!实际上只有12厘米,因此,我们看到的是整个火腿肠都有辣椒酱。现在,dashoffset也是15厘米,也就是虚线要往后偏移15厘米,结果,辣椒酱要抹在火腿肠之外,也就是火腿肠上什么辣椒酱也没有。如果换成上面的直线SVG,也就是直线看不见了。我们把dashoffset值逐渐变小,则会发现,火腿肠上的辣椒酱一点一点出现了,好像辣椒酱从火腿肠根部涂抹上去一样。
<style type="text/css"> body{background-color:#00688B; } .text{font-size: 64px; font-weight: normal; text-transform: uppercase; fill:none; stroke: #B0E0E6; stroke-width: 2px; stroke-dasharray: 90 310; animation: stroke 6s infinite linear; } .text-1{stroke: #FFEC8B; animation-delay:-1.5s; text-shadow:5px 5px 5px #FFEC8B; } .text-2{stroke:#AEEEEE; animation-delay:-3s; text-shadow:5px 5px 5px #7FFFD4; } .text-3{stroke:#EEE0E5;animation-delay:-4.5s;text-shadow:5px 5px 5px #7FFFD4; } .text-4{stroke:#FFC1C1;animation-delay:-6s;text-shadow:5px 5px 5px #7FFFD4; } @keyframes stroke { to { stroke-dashoffset: -400;}} </style> <svg width="100%" height="100"> <text text-anchor="middle" x="50%" y="50%" class="text text-1" > Happy birthday to you❤ </text> <text text-anchor="middle" x="50%" y="50%" class="text text-2" > Happy birthday to you❤</text> <text text-anchor="middle" x="50%" y="50%" class="text text-3" > Happy birthday to you❤ </text> <text text-anchor="middle" x="50%" y="50%" class="text text-4" > Happy birthday to you❤ </text> </svg>
以上就是SVG霓虹灯效果 的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号