3D文字效果
**推荐一个在线运行代码工具,可直接复制过去查看效果:**HTML5在线运行,代码测试 - 在线编辑器(cainiaojc.com)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D文字</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #000;
}
.text-3d {
position: relative;
font-size: 6em;
color: #252839;
-webkit-text-stroke: 0.1vw #383d52;
text-transform: uppercase;
}
.text-3d::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: #01fe87;
-webkit-text-stroke: 0vw #383d52;
border-right: 2px solid #01fe87;
overflow: hidden;
animation: animate 6s linear infinite;
}
@keyframes animate {
0%,
10%,
100% {
width: 0;
}
70%,
90% {
width: 100%;
}
}
</style>
</head>
<body>
<h2 class="text-3d" data-text="3D文字效果">3D文字效果</h2>
</body>
</html>