简体   繁体   English

带jQuery的可滚动内容

[英]scrollable content w/ jquery

I am very new to jQuery, but I thought i would give it a go. 我对jQuery非常陌生,但我想我会尝试一下。 So i have a footer, which i would like to be static on the page. 所以我有一个页脚,我希望它在页面上保持不变。 I have a <section> where i have put a lot of text. 我有一个<section> ,我在其中放置了很多文本。 I want this section to be scrollable so when scrolling only that moves up and down and not the footer. 我希望此部分是可滚动的,以便仅在滚动时上下移动而不在页脚中滚动。

So i have come up with this code so far? 因此,到目前为止,我已经提出了此代码?

 $("#main").mouseover(function(){
           $('#main').scroll();
       });

This is the beginning of the section 这是本节的开始

<section id="main">
         <div id="bio">
          <div class="section_separator">....

Hope i have made some sense? 希望我有道理? And you guys and help me out :) 你们帮我忙:)

将页脚的CSS设置为position: fixed (可能是bottom: 0

This is a CSS issue, not JQuery.... 这是CSS问题,而不是JQuery。

footer{
  position:fixed;
  bottom:0;
}

However, If you only want the page to scroll when you aren't hovering on top of the footer, this is what you want: 但是,如果只希望页面在不悬停在页脚顶部时滚动,这就是您想要的:

$('footer').hover(function(){
    $('html').addClass('scroll_disabled');
}, function(){
    $('html').removeClass('scroll_disabled');
});

$('html.scroll_disabled').on('mousewheel', function(e){
    e.preventDefault();
});

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

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