background-clip:css剪裁GIF背景图片动画特效

css剪裁GIF背景图片动画特效

在这里插入图片描述

HTML结构

 <div class= "wrapper">
    <div class= "text" data-text= "晓风伴月">晓风伴月</div>
 <div>

CSS代码

.wrapper{
     background: #252854;
     width: 100%;
     height:500px;
     border-radius: 5px;
     position: relative;  
 }
 .text{
     flex: 0 0 100%;
     font-size: 10rem;
     font-weight: 900;
     text-align: center;
     font-family: 'Lato', sans-serif;
     position: absolute;
     left: 50%;
     top: 50%;
     transform: translate(-50%, -50%);
     width: 800px;
     color: #00000000;
 }
 
 .text:after{
     content: attr(data-text);
     -webkit-text-stroke: 1.5px #d4d7ff;
     position: absolute;
     left: 50%;
     top: 50%;
     transform: translate(-50%, -49%);
     background: url(./images/bg.gif);
     background-clip: text;
     -webkit-background-clip: text;
     background-size: 43%;
     width: 800px;
 }

background-clip: text

background-clip: text 以区块内的文字作为裁剪区域向外裁剪,文字的背景即为区块的背景,文字之外的区域都将被裁剪掉。

简单而言,就是运用了 background-clip: text 的元素,其背景内容只保留文字所在区域部分,配合透明文字 color: transparent(color: #00000000;),就能够利用文字透出背景。

利用 background-clip: text,能够得到很多非常有意思的文字效果。

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晓风伴月

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值