gpt4 book ai didi

javascript - 如何在我的案例中显示和隐藏元素?

转载 作者:行者123 更新时间:2023-11-28 17:43:16 26 4
gpt4 key购买 nike

我试图在用户点击我的 ul 元素时显示和隐藏一个元素

我有类似的东西

<ul ng-click="expandMenu =!expandMenu"> //when clicks ul, the wrapper shows

</ul>

<div id='wrapper' ng-show='expandMenu' ng-animate="{show:'animate-show', hide:'animate-hide'}">
//contents
</div>

当我单击 ul 时,该元素会按预期显示和隐藏,但我希望动画流畅。

我的CSS

.animate-show, .animate-hide {
-webkit-transition:all linear 1s;
-moz-transition:all linear 1s;
-ms-transition:all linear 1s;
-o-transition:all linear 1s;
transition:all linear 1s;

}

.animate-show {
opacity:0;
}

.animate-show.animate-show-active {
opacity:1;
}

.animate-hide {
opacity:1;
}

我从谷歌找到了上述答案,但我似乎无法让它在我的案例中发挥作用。谁能帮帮我?

谢谢

最佳答案

您实际上不需要所有的 ng-animate 东西,您只需要

.wrapper.ng-hide-add{
display:block !important;
opacity:1;
}

.wrapper.ng-hide-remove{
display:block !important;
opacity:0;
}

关于javascript - 如何在我的案例中显示和隐藏元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23706175/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com