简体   繁体   English

滚动到顶部时出现褪色问题

[英]Issue with fading in a scroll to top

I have a site with a fixed side bar containing the site header and then the site content scrolls on the right. 我有一个带有固定的包含网站标题的侧边栏的网站,然后网站内容在右侧滚动。 I want to fade in a scroll to top button within the header (Sidebar) using something similar to this method http://gazpo.com/2012/02/scrolltop/ but it doesnt seem to be triggering, could it be to do with the site having a fixed sidebar? 我想使用类似于此方法http://gazpo.com/2012/02/scrolltop/的标题(侧边栏)中的滚动到顶部按钮的淡入淡出效果,但似乎并没有触发,这可能与该站点具有固定的侧边栏?

How would I re-write the jquery to look out for the scrolling content and not the entire page scrolling 我将如何重新编写jQuery,以查找滚动内容而不是整个页面滚动

<script type="text/javascript">
$(document).ready(function(){ 

    $(window).scroll(function(){
        if ($(this).scrollTop() > 100) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    }); 

    $('.scrollup').click(function(){
        $("html, body").animate({ scrollTop: 0 }, 600);
        return false;
    });

});

Thanks 谢谢

It could be one of many things (I'm with StreakyCobra - a jsFiddle would be very useful here) 这可能是很多事情之一(我在StreakyCobra中工作-jsFiddle在这里非常有用)

  • Did you check that "scrollup" is the class of your button, and not "scrollUp"? 您是否检查过“ scrollup”是按钮的类别,而不是“ scrollUp”?

  • What are the CSS properties for .scrollup? .scrollup的CSS属性是什么? Is the display set to none, or the opacity to 0? 是将显示设置为无,还是将不透明度设置为0? If so, the fade in and fade out can not affect it, as you will be fading in or out something that is already not visible. 如果是这样,则淡入和淡出不会对其造成影响,因为您将淡入或淡出已经不可见的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM