【发布时间】:2021-05-06 06:25:46
【问题描述】:
我创建了一个按钮,您可以在其中单击它。然后它会启动一个 CSS 动画,其中一些按钮和文本沿着屏幕向下流动,说你确定要这样做吗?然后他们可以单击是或否按钮,我希望它可以反转动画。我已经完成了向下的动画,但是当他们单击按钮时,我无法重复该动画返回。
这是 HTML:
<button onclick="confirm()">Delete</button>
<div id="wholeshow" class="confirm-whole">
<h1 class="confirm">Delete</h1>
<p class="confirm">Are you sure you want to delete ____?</p>
<button class="confirm" onclick="reset()">Delete</button>
<button class="confirm" onclick="cancel()">Cancel</button>
</div>
这里是 JS:
function confirm() {
document.getElementById("wholeshow").classList.add("add");
}
这里是 CSS:
.confirm-whole {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: grey;
animation: slideIn 0.5s forwards;
}
@keyframes slideIn {
0% {
top: -250px;
height: 0%;
}
99% {
height: 0%;
}
100% {
top: 0px;
height: 100%;
}
}
.add {
display: block;
}
非常感谢您的帮助!
【问题讨论】:
-
按
confirm-whole后是否要再次返回display: none?
标签: javascript html css