我正在建立我自己的网站的第二版,我正在try 制作一个弹出式幻灯片动画.问题是,我试着做了一个,但我总是搞砸了,没有什么能让它起作用.我做了一个滑入动画,很管用,但现在我需要一个滑出动画.
如何为弹出窗口制作滑出弹出动画.如果有人能帮忙,我将不胜感激!
代码如下所示:
function openPopup() {
document.getElementById("popup").style.display = "block";
}
function closePopup() {
document.getElementById("popup").style.display = "none";
}
.popup {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
align-items: center;
justify-content: center;
z-index: 9999;
}
.popup-content {
background-color: #ffffff;
padding: 20px;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
text-align: center;
width: 400px;
height: 400px;
position: relative;
right: -600px;
top: 200px;
animation: popUPAnimation 1s forwards;
}
@keyframes popUPAnimation {
0% {
transform: scale(0);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
.popup-content h1 {
color: #333333;
font-size: 2.5rem;
text-align: center;
text-decoration: underline;
}
.popup-content h2 {
color: #333333;
font-size: 1.3rem;
text-align: center;
margin-top: 10px;
}
.solid-popup {
position: absolute;
border-top: 1px solid #bbb;
width: 70%;
margin-top: 20px;
margin-left: 40px;
}
.popup-content button {
background: #EEEEEE;
border: none;
border-radius: 5px;
padding: 5px 10px;
margin: 10px;
position: relative;
top: 30px;
cursor: pointer;
transition: all .45s ease;
}
.popup-content button:hover {
background: #dedede;
}
.popup-close {
position: absolute;
top: -10px;
right: 5px;
font-size: 3rem;
cursor: pointer;
color: #333333;
transition: all .45s ease;
}
.popup-close:hover {
transform: scale(1.1);
color: #0f0f0f;
}
<button onclick="openPopup()">Open popup</button>
<div id="popup" class="popup">
<div class="popup-content">
<span class="popup-close" onclick="closePopup()">×</span>
<h1>Sort products</h1>
<h2>Categories</h2>
<hr class="solid-popup">
<div class="popup-buttons">
<div>
<button onclick="window.location.href='#';">General Websites</button>
</div>
<div>
<button onclick="window.location.href='#';">Fivem Websites</button>
</div>
<div>
<button onclick="window.location.href='#';">Custom made websites</button>
</div>
<div>
<button onclick="window.location.href='#';">Ecommerce Websites</button>
</div>
<div>
<button onclick="window.location.href='#';">All Websites</button>
</div>
</div>
</div>
</div>