Я создаю свой первый HTML / CSS / js веб-сайт и начал работать с всплывающими окнами сегодня, используя Animista. Я делаю простой всплывающий модуль масштабирования / масштабирования, который масштабируется при нажатии кнопки и масштабируется при нажатии кнопки закрытия.
По некоторым причинам это работает только один раз : Я закрываю всплывающее окно, оно не отображается при повторном нажатии кнопки. Это работает, только если я перезагрузить страницу. (Сейчас я работаю локально) Я сам искал ответ, но не могу найти ничего полезного (наверное, я неправильно ввел ключевые слова в Google ...).
Извините, если вопрос очевиден - я очень новый для веб-разработки. Большое спасибо !!
См. Код ниже:
css:
.scale-in-tr {
-webkit-animation: scale-in-tr 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: scale-in-tr 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
/* ----------------------------------------------
* Generated by Animista on 2020-3-6 10:48:23
* Licensed under FreeBSD License.
* See http://animista.net/license for more info.
* w: http://animista.net, t: @cssanimista
* ---------------------------------------------- */
/**
* ----------------------------------------
* animation scale-up-tr
* ----------------------------------------
*/
/* ----------------------------------------------
* Generated by Animista on 2020-3-6 11:13:44
* Licensed under FreeBSD License.
* See http://animista.net/license for more info.
* w: http://animista.net, t: @cssanimista
* ---------------------------------------------- */
/**
* ----------------------------------------
* animation scale-in-tr
* ----------------------------------------
*/
@-webkit-keyframes scale-in-tr {
0% {
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
}
@keyframes scale-in-tr {
0% {
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
}
.scale-out-tr {
-webkit-animation: scale-out-tr 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
animation: scale-out-tr 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
}
/* ----------------------------------------------
* Generated by Animista on 2020-3-6 11:47:17
* Licensed under FreeBSD License.
* See http://animista.net/license for more info.
* w: http://animista.net, t: @cssanimista
* ---------------------------------------------- */
/**
* ----------------------------------------
* animation scale-out-tr
* ----------------------------------------
*/
@-webkit-keyframes scale-out-tr {
0% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
100% {
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
}
@keyframes scale-out-tr {
0% {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
100% {
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transform-origin: 100% 0%;
transform-origin: 100% 0%;
opacity: 1;
}
}
body {
height: 100%;
width: 100%;
position: fixed;
background-color: black;
}
header {
display: flex;
min-height: 150px;
width: auto;
justify-content: space-between;
align-items: flex-start;
margin-top: 30px;
margin-left: 30px;
margin-right: 30px;
}
.box-two {
width: 75px;
height: 75px;
cursor: pointer;
border: none;
outline: none;
background-color: black;
}
.box {
width: 75px;
height: 75px;
cursor: pointer;
background-color: black;
border: none;
outline: none;
}
.wrapper {
display: flex;
align-items: center;
justify-content: center ;
max-height: 400px;
min-height: 150px;
}
.three {
display: flex;
align-items: center;
justify-content: center ;
margin: auto;
height: 300px;
width: 600px;
}
.na {
height: 150px;
}
footer {
display: flex;
min-height: 150px;
width: auto;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 30px;
margin-left: 30px;
margin-right: 30px;
}
.invis {
background-color: blue;
align-self: auto;
visibility: hidden;
}
.four {
align-self: auto;
}
.five {
width: 65px;
cursor: pointer;
}
.pop-up {
background-color: black;
border: 1.5px solid white;
border-radius: 20px;
z-index: 10;
width: 350px;
max-width: 80%;
transform: scale(0);
position: absolute;
right: 70px;
top: 70px;
/* opacity: 0;
visibility: hidden;*/
}
.pop-up-active {
opacity: 1;
visibility: visible;
}
.pop-up.about-containter {
display: flex;
justify-content: center;
padding: 20px 20px;
color: white;
}
.about-text {
color: white;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
padding: 15px 15px;
}
.pop-up-footer {
display: flex;
justify-content: center;
}
.close-pop {
cursor: pointer;
border: none;
outline: none;
background: none;
font-size: 4rem;
color: white;
font-weight: lighter;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
js:
var boxTwo = document.querySelector('.box-two');
boxTwo.addEventListener("click", e => {
document.querySelector(".pop-up").classList.toggle("scale-in-tr")
});
var closePop=document.querySelector('.close-pop');
closePop.addEventListener("click", e=>{
document.querySelector(".pop-up").classList.toggle("scale-out-tr")
});