text-stroke实现文字描边(镂空)、text-fill-color实现文字填充&渐变(+animation实现流光字体)...

本文介绍了如何使用 Webkit 的特定属性实现文字描边及渐变填充效果,并提供了动画示例。通过设置 text-stroke 和 text-fill-color 属性,可以在支持 Webkit 的浏览器中创建动态变化的文字效果。

text-stroke:<' text-stroke-width '> || <' text-stroke-color '>(text-stroke-width:设置或检索对象中的文字的描边厚度、text-stroke-color:设置或检索对象中的文字的描边颜色)

<h2 id="demo">这是描了1像素的文字</h2>
#demo{
    color:#555;
    -webkit-text-stroke:1px #f00;
    -webkit-animation:cliptext 7.5s linear infinite;
}
@-webkit-keyframes cliptext{
    0%{-webkit-text-stroke:1px #c00;}
    25%{-webkit-text-stroke:1px #ff0;}
    50%{-webkit-text-stroke:1px #090;}
    75%{-webkit-text-stroke:1px #00f;}
    100%{-webkit-text-stroke:1px #93c;}
}

 

text-fill-color:<color><color>:指定文字的填充颜色。)

<div class="masked">这是一段渐变(流光)文字</div>
.masked{
    background-image: -webkit-linear-gradient(left, #147B96, #E6D205 25%, #147B96 50%, #E6D205 75%, #147B96);
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    -webkit-background-size: 200% 100%;
    -webkit-animation: masked-animation 3s infinite linear;
}
@-webkit-keyframes masked-animation {
    0%  { background-position: 0 0;}
    100% { background-position: -100% 0;}
}

目前仅webkit核心的浏览器下支持此属性

转载于:https://www.cnblogs.com/DaoBaNan/p/8986390.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值