微信视频号点赞动画CSS3实现
【摘要】
大家好!今天分享一个动画,起初实在微信刷视频号时看到的,之前还没有,第一眼我就爱了,动画设计很大胆,于是我就使用CSS3的动画浅浅防了一下,看效果😎
html
<!DOCTYPE html&...
大家好!今天分享一个动画,起初实在微信刷视频号时看到的,之前还没有,第一眼我就爱了,动画设计很大胆,于是我就使用CSS3的动画浅浅防了一下,看效果😎
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>点赞动画</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div class="contianer">
<video src="./你的名字.mp4" autoplay muted loop>
你的浏览器不支持哦
</video>
<svg onclick="fabulous()" t="1652849998021" class="love" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="1958">
<path
d="M32 407.584a279.584 279.584 0 0 1 480-194.944 279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952l-308.16-270.688A278.976 278.976 0 0 1 32 407.584z"
p-id="1959"></path>
</svg>
<svg onclick="fabulous()" t="1652849998021" class="love1" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg" p-id="1958">
<path
d="M32 407.584a279.584 279.584 0 0 1 480-194.944 279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952l-308.16-270.688A278.976 278.976 0 0 1 32 407.584z"
p-id="1959"></path>
</svg>
<img src="./tou.jpg" alt="">
<span>周棋洛♥</span>
<p>世间最美的文字 就是你的名字</p>
</div>
<script>
let love = document.querySelector(".love");
let img = document.querySelector("img");
let span = document.querySelector("span");
let love1 = document.querySelector(".love1");
let flag = 1;
function fabulous() {
if (flag == 1) {
love.style.fill = "red";
love.style.stroke = "red";
img.style.animation = "touflash linear .5s forwards";
span.style.animation = "ziflash ease-in .5s forwards";
love1.style.animation = "love1 1.3s";
flag = 0;
} else {
love.style.fill = "transparent";
love.style.stroke = "#FFF";
flag = 1;
img.style.animation = "";
span.style.animation = "";
love1.style.animation = "";
}
}
</script>
</body>
</html>
css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #000;
}
.contianer {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
video {
width: 40vw;
}
.love {
position: absolute;
width: 30px;
height: 30px;
fill: transparent;
stroke: rgb(180, 180, 180);
stroke-width: 30px;
bottom: 130px;
right: 500px;
cursor: pointer;
}
.love1 {
position: absolute;
width: 80px;
height: 80px;
fill: transparent;
}
img {
position: absolute;
bottom: 130px;
right: 500px;
width: 0px;
height: 0px;
user-select: none;
border-radius: 5px;
}
span {
color: rgb(242, 242, 242);
position: absolute;
left: 521px;
top: 455px;
font-weight: bold;
user-select: none;
opacity: 0;
}
p {
position: absolute;
color: rgb(176, 176, 176);
left: 458px;
top: 550px;
letter-spacing: .3em;
}
@keyframes touflash {
0% {
transform: translate(0px, 0px);
}
30% {
transform: translate(-156px, -90px);
}
50% {
transform: translate(-270px, -125px);
width: 38px;
height: 38px;
}
85% {
transform: translate(-450px, -140px);
}
90% {
transform: translate(-480px, -135px);
width: 40px;
height: 40px;
}
100% {
transform: translate(-520px, -100px);
width: 40px;
height: 40px;
}
}
@keyframes ziflash {
0% {
opacity: 0;
}
80% {
opacity: .1;
}
100% {
opacity: 1;
}
}
@keyframes love1 {
0% {
width: 0px;
height: 0px;
opacity: .4;
}
25% {
width: 90px;
height: 90px;
fill: rgb(148, 0, 0);
}
50% {
width: 80px;
height: 80px;
fill: rgb(148, 0, 0);
opacity: 1;
}
60% {
fill: rgb(148, 0, 0);
opacity: .5;
}
100% {
opacity: 1;
width: 80px;
height: 80px;
}
}
文章来源: blog.csdn.net,作者:周棋洛ყ ᥱ ᥉,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/m0_53321320/article/details/124873037
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
评论(0)