【发布时间】:2020-11-08 23:48:30
【问题描述】:
我还在学习 JavaScript,对它不太熟悉,或者我完全忘记了它。但我的页面上有一个按钮,如下所示:
function hiddenjs() {
var x = document.getElementById("hiddenjs");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
.hiddenjsa {
margin: 0 auto;
background-color: red;
animation-name: expandz;
animation-duration: 1.5s;
animation-timing-function: ease-out;
animation-delay: 0;
animation-direction: alternate;
animation-fill-mode: both;
animation-play-state: running;
}
@keyframes expandz {
0% {
transform: scale(.3);
background-color: red;
border-radius: 100%;
}
50% {
background-color: rgb(71, 8, 8);;
}
100% {
transform: scale(1.5);
background-color: rgb(139, 139, 3);
}
}
<div class="btn4">
<button class="btn4a" onclick="hiddenjs()">List of Other Games I'm going to review!</button>
</div>
<div id="hiddenjs" class="hiddenjsa">
Note: These are NOT clickable links yet as I have yet to review them and add them to the site.
These are just references to which I am in the process of reviewing!
</div>
我想知道,如果没有 jQuery 或任何其他形式的语言,如果只有通过 JavaScript 的方法,你可以做一个切换按钮来做动画(我已经做过),当你再次单击所述按钮时,它会做动画但相反?
我已经阅读了一些关于它的内容,但是如果没有复制和粘贴 jQuery sn-p 就找不到一些东西,我不想这样做,因为我想了解我在做什么。
【问题讨论】:
-
不,这是不可能的,但您可以创建另一个关键帧,然后从那里反转步骤?然后,您决定在哪个时刻启动什么动画。
-
如何将它与单击按钮一起“关闭”我正在执行的显示/隐藏按钮?
-
改用过渡。它们只适合这种类型的东西。
标签: javascript html jquery css animation