Как убрать видимость блока в анимации?
Нужно, чтобы исчезал блок, но когда я делаю это через opacity, не могу ничего нажать, так как блок по сути все еще находится там, но прозрачный.
<body>
<header>
<!-- header-->
</header>
<footer>
<!-- footer-->
</footer>
<div class="over-all">
<!-- Этот блок находится поверх остальных, после чего исчезает -->
</div>
.over-all {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white;
animation-name: over-all2;
animation-fill-mode: forwards;
animation-delay: 0.8s;
animation-duration: 0.8s;
display: flex;
justify-content: center;
align-items: center;
@keyframes over-all2 {
0% {
opacity: 1;
padding-top: 0;
}
100% {
opacity: 0;
padding-top: 0;
}
Ответы (2 шт):
Автор решения: highpassion
→ Ссылка
Добавляйте изменение по высоте, чтобы элемент не находился поверх остальных после анимации. Очень важно, чтобы начальное и конечное значения высоты были численными, иначе анимация не сработает (можно оставить height: auto, а манипулировать значениями max-height)
header, footer {
width: 100%;
height: 50vh;
border: 1px solid #000;
background: yellow
}
header {
background: blue;
border-bottom: 0;
}
.over-all {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-color: white;
animation-name: over-all2;
animation-fill-mode: forwards;
animation-delay: 0.8s;
animation-duration: 0.8s;
display: flex;
justify-content: center;
align-items: center;
background: red;
}
@keyframes over-all2 {
0% {
opacity: 1;
padding-top: 0;
height: 100vh;
}
100% {
opacity: 0;
padding-top: 0;
height: 0;
}
<header>
<!-- header-->
</header>
<footer>
<!-- footer-->
</footer>
<div class="over-all">
<!-- Этот блок находится поверх остальных, после чего исчезает -->
</div>
Если вам неподходит анимация изменения высоты, можете манипулировать значениями z-index.
header, footer {
width: 100%;
height: 50vh;
border: 1px solid #000;
background: yellow
}
header {
background: blue;
border-bottom: 0;
}
.over-all {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-color: white;
animation-name: over-all2;
animation-fill-mode: forwards;
animation-delay: 0.8s;
animation-duration: 0.8s;
display: flex;
justify-content: center;
align-items: center;
background: red;
}
@keyframes over-all2 {
0% {
opacity: 1;
padding-top: 0;
z-index: 1;
}
100% {
opacity: 0;
padding-top: 0;
z-index: -1;
}
<header>
<!-- header-->
</header>
<footer>
<!-- footer-->
</footer>
<div class="over-all">
<!-- Этот блок находится поверх остальных, после чего исчезает -->
</div>
Автор решения: Qwerty Q
→ Ссылка
Пожалуйста!
@keyframes over-all2 {
0% {
opacity: 1;
padding-top: 0
}
100% {
opacity: 0;
visibility: hidden
}
}