【发布时间】:2019-01-31 18:58:03
【问题描述】:
大家好,我正试图向您展示隐藏并钉在导航栏上方,我得到了它的显示,但是他的动画在隐藏时不起作用..有人可以帮我修复它吗?
查看fiddle
// CSS
.margin-top-0 { margin-top: 0px !important; }
.margin-top-20 { margin-top: 20px !important; }
.margin-top-40 { margin-top: 40px !important; }
.alert-server {
border-radius: 0;
position:fixed;
top:0;
width:100%;
padding:10px 0;
text-align:center;
display:none;
}
// 显示#notificationBar
setTimeout(function () {
// working
$("#notificationBar").css({"display":"block"});
$('#notificationBar').html('Hello User! Welcome!').addClass('margin-top-0', 2000);
$('body, .navbar').addClass('margin-top-40', 2000);
}, 2000);
// 隐藏#notificationBar
setTimeout(function () {
// not working
$('#notificationBar').removeClass('margin-top-0', 2000).html().css({"display":"none"});
$('body, .navbar').removeClass('margin-top-40', 2000);
}, 6000);
// HTML
<body>
<div id="notificationBar" class="alert alert-success alert-server" role="alert" style="display: none; overflow: hidden; z-index: 9999; margin-top: -40px;">
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<div class="navbar-spacer" style="min-height:60px;"></div>
<!-- Fixed navbar -->
<nav class="website-nav navbar navbar-default navbar-fixed-top">
<div class="navbar-inner">
<div class="nav-center">
</div>
</div>
</nav>
【问题讨论】:
-
能否请您添加一个 JS Fiddle 链接。
-
请检查您的浏览器控制台是否有错误并将其复制到此处以便我们解决?
-
@AhmedHammad 我在控制台中没有错误。它正在隐藏,但隐藏时的动画不起作用...我想看到它向上滑动。
-
@Anji 我会贴在那里
-
如何将其添加到边距类中:“过渡:所有 2s 线性”。
标签: jquery twitter-bootstrap jquery-ui navbar