English 中文(简体)
div 不在滚动上消失, 因为溢出: hidden / 自动
原标题:div not disappearing on scroll because of overflow:hidden / auto

我得到了这个 JavaScript( JavaScript)

$(window).load(function(){
var $menu = $("header");
var opacity = $menu.css("opacity");
var scrollStopped;

var fadeInCallback = function () {
    if (typeof scrollStopped !=  undefined ) {
        clearInterval(scrollStopped);
    }

    scrollStopped = setTimeout(function () {
        $menu.animate({ opacity: 1 }, "slow");
    }, 1400);
}

$(window).scroll(function () {
    if (!$menu.is(":animated") && opacity == 1) {
        $menu.animate({ opacity: 0 }, "200", fadeInCallback);
    } else {
        fadeInCallback.call(this);
    }
  });
});

它将页眉隐藏在卷轴上,但增加了一定的高度:100%;在html、身体和内容中,隐藏在html、身体和内容的外溢部分隐藏在html和身体上;在内容中,隐藏在内容上,显示该javascript不再起作用。

知道为什么这个刺青不起作用吗? 是否有固定方法或其他方法可以让页眉在滚动时消失?

提前感谢

编辑 - - -

AJFiddle - < a href=>http://jsfiddle.net/sturobson/AMJFG/" rel="no follow">http://jsfiddle.net/sturobson/AMJFG/

较新的CSS低的中小乐团-http://jsfiddle.net/sturobson/AMJFG/1/

最佳回答

你的剧本为我工作

但如果你想尝试另一种方法,

$(document).ready(function(){
    headerFade();
});
function headerFade() {
    var $menu = $("header"),
        opacity = $menu.css("opacity"),
        scrollStopped,
        methods = {
            init: function(){               
                $(window).scroll(function () {
                    (!$menu.is(":animated") && opacity == 1) ? $menu.fadeOut(200, methods.fadeInCallback()) : methods.fadeInCallback();                 
                });             
            },
            fadeInCallback: function(){             
                clearInterval(scrollStopped);                               
                scrollStopped = setTimeout(function () {
                    $menu.fadeIn(600);
                }, 1400);
            }
        };  
    methods.init();
};
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签