Css3聚光灯动画特效

一、预览效果🚀

在这里插入图片描述

二、代码讲解

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

前端阿皓

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

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

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

打赏作者

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

抵扣说明:

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

余额充值