Fixed Position div Vertical Only

房东的猫 提交于 2019-12-03 12:57:21

问题


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.

What I am looking for is to have the content scrollable horizontally to the right when it is out of the viewport window. Any help would be greatly appreciated.

similarly to this: http://demo.rickyh.co.uk/css-position-x-and-position-y/ however I can not get this working.


This has been solved by alternative method. Thanks for those who actually considered helping.


回答1:


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());
});



回答2:


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;
}



回答3:


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.



来源:https://stackoverflow.com/questions/6067603/fixed-position-div-vertical-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!