新增第112个小实例:纯CSS实现文本背景扫光效果

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2022-02-18 16:35:26 +08:00
parent 3e06d737cb
commit 50abb7af30
3 changed files with 56 additions and 1 deletions

View File

@ -115,4 +115,5 @@
108. HTML5+CSS3+JS小实例漂亮的导航栏动画效果
109. HTML5+CSS3小实例灵动的文字loading加载特效
110. HTML5+CSS3小实例百看不腻的旋转loading动画
111. HTML5+CSS3+JQuery小实例DIY切换衣服图案
111. HTML5+CSS3+JQuery小实例DIY切换衣服图案
112. HTML5+CSS3小实例纯CSS实现文本背景扫光效果

38
code/112/112.css Normal file
View File

@ -0,0 +1,38 @@
*{
/* 初始化 */
margin: 0;
padding: 0;
}
body{
height: 100vh;
/* 弹性布局 水平+垂直居中 */
display: flex;
justify-content: center;
align-items: center;
background-color: #000;
}
h1{
/* 文本透明 */
color: transparent;
font-size: 60px;
letter-spacing: 5px;
/* 渐变背景 */
background: linear-gradient(to right,#000,#fff,#000);
/* 裁剪掉文字以外的区域 */
-webkit-background-clip: text;
background-size: 80%;
background-repeat: no-repeat;
background-position: center;
/* 执行动画:动画名 时长 线性 无线播放 */
animation: move 2s linear infinite;
}
/* 定义动画 */
@keyframes move {
0%{
background-position: -500%;
}
100%{
background-position: 500%;
}
}

16
code/112/112.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>纯CSS实现文本背景扫光效果</title>
<link rel="stylesheet" href="112.css">
</head>
<body>
<h1>Hello World, Hello Everybody!</h1>
</body>
</html>