新增第242个小实例:点画文字悬停效果

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2024-03-11 17:44:15 +08:00
parent f3f386c73c
commit 71e4fe26fc
3 changed files with 66 additions and 0 deletions

View File

@ -249,6 +249,7 @@
239. HTML5+CSS3小实例飞行滑块
240. HTML5+CSS3小实例无限循环loading动画
241. HTML5+CSS3+JS小实例旋转渐变光标
242. HTML5+CSS3小实例点画文字悬停效果
#### 赞赏作者
![image](https://gitee.com/wyanhui02/html_css_demo/raw/master/images/%E8%B5%9E%E8%B5%8F%E4%BD%9C%E8%80%85/%E8%B5%9E%E8%B5%8F%E7%A0%81.jpg)

53
code/242/242.css Normal file
View File

@ -0,0 +1,53 @@
/* 引入字体 */
@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
height: 100vh;
background: radial-gradient(#631249,#17151d);
display: flex;
justify-content: center;
align-items: center;
}
h1{
position: relative;
font-size: 150px;
color: #f6d8d5;
font-family: "Poppins";
width: fit-content;
}
h1::before{
content: attr(data-text);
color: #313f97;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: -1;
/* 动画过渡 */
transition: 0.2s;
}
h1:hover::before{
top: 0.04em;
left: 0.04em;
}
h1::after{
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
color: transparent;
background: radial-gradient(rgba(236,34,37,0.5) 0.0125em, transparent 0.0125em);
background-size: 8px 8px;
background-clip: text;
-webkit-text-stroke: 1px #ec2225;
transition: 0.2s;
}
h1:hover::after{
top: -0.04em;
left: -0.04em;
}

12
code/242/242.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>点画文字悬停效果</title>
<link rel="stylesheet" href="242.css">
</head>
<body>
<h1 data-text="HELLO WORLD!">HELLO WORLD!</h1>
</body>
</html>