当我滚动它时,我尝试做淡出工作但是当我滚动到顶部时,元素被隐藏 我使用插件隐藏
JADE
#header
.container
#content
h3.post-logo ACHRAF
h1.post-behind A
h2.title.animate.fadeInUp Développeur Mobile
h2.title & Web
JQUERY
$(window).scroll( function(){
if($('#header:hidden'))
$('#header').addClass('animated fadeOut');
else
$('#header').addClass('animated fadeInUp');
});
答案 0 :(得分:0)
您可以使用以下代码轻松淡出和淡入:
if($('#header:hidden'))
$('#header').fadeOut(100);
else
$('#header').fadeIn(100);
答案 1 :(得分:0)
试试这个(http://jsfiddle.net/2p4x52up/)...
<div id="header"></div>
<div class="content"></div>
... JS
$(window).on("scroll", function(e) {
if ($(window).scrollTop() >= $("#header").height()) $("#header").fadeOut(500);
else $("#header").fadeIn(500);
});
... CSS
#header {
background: red;
height: 100px;
left: 0;
position: fixed;
top: 0;
width: 100%;
}
.content {
float: left;
width: 100%;
height: 2000px;
background: gray;
}