首页 > Web开发 > 详细

js实现文字分割动画

时间:2021-05-03 19:00:39      阅读:16      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
body {
height: 100%;
background: white;
}

h1 {
color: black;
text-align: center;
font-size: 10vw;
position: relative;
font-weight: 900;
text-transform: uppercase;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
margin: 0;
}

h1:before,
h1:after {
content: attr(data-heading);
position: absolute;
left: 0;
width: 100%;
text-align: center;
}

h1:before {
clip-path: polygon(0 0, 100% 0%, 100% 39%, 0 67%);
color: white;
text-shadow: 3px -2px 5px white, -3px 3px 4px white;
background: white;
}

h1:after {
clip-path: polygon(0 0, 100% 0%, 100% 37%, 0 65%);
color: black;
animation: fracture 5s infinite ease;
}

@keyframes fracture {
0% {
transform: translateX(0);
}

50% {
transform: translate(-20px, 2%);
}
}
</style>
</head>
<body>
<h1 contenteditable data-heading="悠酒网">悠酒网</h1>

</body>
<script type="text/javascript">
var h1 = document.querySelector("h1");
h1.addEventListener("input", function() {
this.setAttribute("data-heading", this.innerText);
});
</script>
</html>

js实现文字分割动画

原文:https://www.cnblogs.com/jimyking/p/14727550.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!