一、预览效果🚀
二、代码讲解
1、clip-path:ellipse(100px 100px at 0% center);
//裁剪可显示区域 裁剪一个100*100的区域 从0%的位置开始 垂直居中
2、background-clip: text
//背景绘制区域给文字本身
三、全部代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
body,html{
width: 100%;
height: 100%;
background-color: #222;
}
.box{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.box>h1{
font-size: 46px;
color: #333;
position: relative;
}
.box>h1::after{
content: 'This is a huge bug,This is a huge bug';
position: absolute;
top: 0;
left: 0;
color: transparent;
clip-path:ellipse(100px 100px at 0% center); /*裁剪可显示区域*/
animation: ellipseD 4s infinite;
background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fserver.xmyeditor.com%2Fpicture%2F30%2F0d484408dcbdaf7e3024e800b4eefa10.jpg&refer=http%3A%2F%2Fserver.xmyeditor.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641626039&t=37e691111617ce60708463e392e338b7');
background-size: 100% 100%;
background-position: center center;
background-clip: text; /*背景绘制区域给文字本身*/
-webkit-background-clip: text;
}
@keyframes ellipseD{
0%{
clip-path:ellipse(100px 100px at 0% center);
}
50%{
clip-path:ellipse(100px 100px at 100% center);
}
100%{
clip-path:ellipse(100px 100px at 0% center);
}
}
</style>
</head>
<body>
<div class="box">
<h1>This is a huge bug,This is a huge bug</h1>
</div>
</body>
</html>