简体   繁体   English

如何使侧边栏像有线网站一样滚动?

[英]how to get sidebar scrolling like wired website?

i have tried to replicate the sibebar scrolling used on wired.com but no luck yet :/ 我试图复制上wired.com使用的sibebar滚动 ,但没有运气尚未:/

link - https://www.wired.com/story/the-bike-share-war-is-shaking-up-seattle-like-nowhere-else/ 链接 -https://www.wired.com/story/the-bike-share-war-is-shaking-up-seattle-like-nowhere-else/

few things i have noticed- 我注意到的几件事-

  1. the sidebar changes height dynamically depending on the content(can be a big picture or an ad) which is wider than the content in the middle portion 侧边栏会根据内容(可以是大图片或广告)动态更改高度,该内容比中间部分的内容宽
  2. then it gets pushed up by that content. 然后它被该内容推高了。
  3. After all have moved up, the sidebar appears again and sticks until it comes in contact with any such content. 在全部向上移动之后,侧栏再次出现并停留直到它与任何此类内容接触为止。

    i checked the source and it seems the sidebar is finding the height of the wider content and matching to it , and then the next , and in the last its 100% 我检查了源,似乎侧边栏正在查找较宽内容的高度并与之匹配,然后是下一个,最后是其100%

在此处输入图片说明

PS - i am new to web development and any help would be immensely appreciated :) , thanks: PS-我是Web开发的新手,我们将不胜感激:),谢谢:

this is what i have tried 这就是我尝试过的

        $(function(){
    var d = $('#sidebar');
    var dPosTop = d.offset().top;
    var win = $(window);
    win.scroll(function(e){
        var scrollTop = win.scrollTop();
        if(scrollTop >= dPosTop){
          d.fadeIn(500);
        }
      else{
        d.fadeOut(200);
      }
    });

});


$(document).ready(function(){
$("#sidebar").height( $("#content").height() );
});

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

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