css 实现流光字体效果

<template>
<div>
    <p data-text="Lorem ipsum dolor"> Lorem ipsum dolor </p>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss">
html, body {
    width: 100%;
    height: 100%;
    background-image: radial-gradient(ellipse  farthest-side at 44% 16%, #455A64 0%, #263238 105%, #1a2327 268% );
    margin: 0;
    color: #E8A95B;
    display: flex;
}
p {
    position: relative;
    margin: auto;
    font-size: 50px;
    word-spacing: 10px; // 规定文字中间的空格为 10px
    display: inline-block;
    white-space: nowrap;
    color: transparent;  // transparent - 透明
    background-color: #E8A95B;
    -webkit-background-clip: text; // 兼容其他浏览器 规定以 文字 裁剪 background-clip 规定以什么地方裁剪 text - 文字
}
p::after {
    content: attr(data-text);  // content 语法与属性值: attr(attribute) -- 将元素的 attribute 属性以字符串形式返回。
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: 5;
    //
    background-image: linear-gradient(
        120deg,
        transparent 0px,
        rgb(101, 13, 243) 0px,
        transparent 60px,
        rgba(223, 203, 203, .3) 0px,
        transparent -60px,
        rgb(101, 13, 243) 200px,
        transparent -160px,
        rgba(223, 203, 203, .3) 200px,
        transparent 0px,
        rgb(101, 13, 243) 0px,
    );
    background-clip: text;
    background-size: 150%;
    animation: shine 8s infinite linear;
}
@keyframes shine {
    0% {
        background-position: 50% 0;
    }
    100% {
        background-position: -190% 0;
    }
}
</style>
转自: https://csscoco.com/inspiration/#/./background/bg-clip-text-shine.md
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值