Я создал анимацию, которая др aws и анимирует три строки.
- сверху, справа налево
- слева, сверху вниз
- снизу, слева направо.
Оболочка содержимого - display: none
, и при нажатии на #btn
она отображается и анимируется строка. Я ожидаю, что анимация строки второго щелчка развернется, и оболочка содержимого должна go вернуться к display: none
.
Я попробовал приведенный ниже код, но он не работал. Кто-нибудь может дать мне несколько советов, что делать?
$('#btn').click(function() {
var clicks = $(this).data('clicks');
if (clicks) {
$('.content-wrapper').css({
'display': 'none'
});
} else {
$('.content-wrapper').css({
'display': 'block'
});
}
$(this).data("clicks", !clicks);
});
.content-wrapper {
display: none;
width: 68.5%;
height: 60%;
position: absolute;
top: 25%;
left: 50%;
transform: translate(-50%);
}
.l-top,
.l-left,
.l-bottom {
position: absolute;
background: transparent;
-webkit-animation-duration: .4s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-fill-mode: both;
-webkit-animation-direction: alternate;
}
.l-top {
top: 0;
right: 0;
height: 1px;
-webkit-animation-name: l-top;
-webkit-animation-delay: 0s;
}
.l-left {
top: 0;
left: 0;
width: 1px;
-webkit-animation-name: l-left;
-webkit-animation-delay: .4s;
}
.l-bottom {
left: 0;
bottom: 0;
height: 1px;
-webkit-animation-name: l-bottom;
-webkit-animation-delay: .8s;
}
@-webkit-keyframes l-top {
0% {
width: 0;
background: red;
}
100% {
width: 100%;
background: red;
}
}
@-webkit-keyframes l-left {
0% {
height: 0;
background: red;
}
100% {
height: 100%;
background: red;
}
}
@-webkit-keyframes l-bottom {
0% {
width: 0;
background: red;
}
100% {
width: 100%;
background: red;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="btn">btn</btn>
<div class="content-wrapper">
<span class="l-top"></span>
<span class="l-left"></span>
<span class="l-bottom"></span>
<p>content</p>
</div>