可见性"animation"但延迟了 SCSS 中的反向效果



我正在创建一个最初想要隐藏的元素,但当添加一个类时,它会出现并为顶部设置动画。这样做的问题是,在移除类时,可见性会立即触发,然后顶部会设置动画。在SCSS中,我如何确保类上移除的可见性直到顶部动画之后才受到影响?

$(window).on("load", function(){
$("button").click(function(){
$(".nav-slider").toggleClass("is_visible");
});
});
.nav-slider {
position:fixed;
top:-100%;
left:0;
width:100%;
height:calc(100% - 60px);
background-color:$white;
z-index:1;
visibility:hidden;
transition:top 0.2s, visibility 0s;
-o-transition:top 0.2s, visibility 0s;
-ms-transition:top 0.2s, visibility 0s;
-moz-transition:top 0.2s, visibility 0s;
-webkit-transition:top 0.2s, visibility 0s;
padding-top:40px;
}
.nav-slider.is_visible {
top:60px;
visibility: visible;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="nav-slider">
test
</div>
<button>slider</button>

您可以对.is_visible进行不同的转换

$(window).on("load", function() {
$("button").click(function() {
$(".nav-slider").toggleClass("is_visible");
});
});
.nav-slider {
position: fixed;
top: -100%;
left: 0;
width: 100%;
height: calc(100% - 60px);
background-color: $white;
z-index: 1;
visibility: hidden;
padding-top: 40px;
transition: top 2s, visibility 2s;
}
.nav-slider.is_visible {
transition: top 2s, visibility 0s;
top: 60px;
visibility: visible;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="nav-slider">
test
</div>
<button>slider</button>

相关内容

  • 没有找到相关文章

最新更新