简体   繁体   English

粘边栏与页脚重叠?

[英]Sticky sidebar overlaps to the footer?

I have Created custom sticky sidebar for ADS, it works but there is an issue. 我已经为ADS创建了自定义粘性侧边栏,它可以工作,但是有一个问题。 when I scroll it to the bottom, it overlaps on the footer. 当我滚动到底部时,它与页脚重叠。 pls check. 请检查。 - http://screencast.com/t/oEjcrbocB05C -http://screencast.com/t/oEjcrbocB05C

 var stickySidebar = $('.sticky'); if (stickySidebar.length > 0) { var stickyHeight = stickySidebar.height(), sidebarTop = stickySidebar.offset().top; } // on scroll move the sidebar $(window).scroll(function () { if (stickySidebar.length > 0) { var scrollTop = $(window).scrollTop(); if (sidebarTop < scrollTop) { stickySidebar.css('top', scrollTop - sidebarTop); // stop the sticky sidebar at the footer to avoid overlapping var sidebarBottom = stickySidebar.offset().top + stickyHeight, stickyStop = $('.main-content').offset().top + $('.main-content').height(); if (stickyStop < sidebarBottom) { var stopPosition = $('.main-content').height() - stickyHeight; stickySidebar.css('top', stopPosition); } } else { stickySidebar.css('top', '0'); } } }); $(window).resize(function () { if (stickySidebar.length > 0) { stickyHeight = stickySidebar.height(); } }); 
 .sticky { position: relative; top: 0; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

Check for site url is - http://www.test2.guru99.com/java-tutorial.html 检查网站网址是否为-http: //www.test2.guru99.com/java-tutorial.html

Please Help Me ! 请帮我 !

Modify your following CSS 修改您的以下CSS

#rt-footer-surround {
  background-color: #3f3f3f;
  color: #f8f8f8;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.1);
}

To this, Add position:relative and z-index:1 为此,添加position:relativez-index:1

#rt-footer-surround {
  background-color: #3f3f3f;
  color: #f8f8f8;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1;
}

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

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