Fixed Position div Vertical Only

前端 未结 3 1740
攒了一身酷
攒了一身酷 2021-02-06 04:33

I have a current web build with a right sidebar that is a fixed position. I have tried to positioning from the right but don\'t want it overlapping other divs content.

W

相关标签:
3条回答
  • 2021-02-06 04:47

    That example site is using more than just css to generate that effect. It is also using a MooTools plugin: ScrollSpy. http://davidwalsh.name/mootools-scrollspy

    View the source at http://demo.rickyh.co.uk/css-position-x-and-position-y/ to see the scripting and the full css.

    0 讨论(0)
  • 2021-02-06 04:48

    Keep the fixed div.

    And have the following javascript code which will take care of horizontal moving.

    $(window).scroll(function(){
      $('.fixed_div').css('left',-$(window).scrollLeft());
    });
    
    0 讨论(0)
  • 2021-02-06 05:04

    then add one more property in #sidebar

    #sidebar {
    width:400px;
    height:550px;
    padding:10px;
    float:left;
    text-transform:uppercase;
    position:fixed;
    left:835px;
    overflow:scroll-x;
    }
    
    0 讨论(0)
提交回复
热议问题