How to make position:fixed div scroll horizontally

匿名 (未验证) 提交于 2019-12-03 00:48:01

问题:

I have a div with position:fixed, as the image below suggests.

I want it to be fixed vertically, but I want it to scroll horizontally with the rest of the content (notice the horizontal scroll bar).

Is this possible with CSS? Or do I need Javascript (in this case, how could I do it)?

回答1:

Old question, but I was also looking for a solution also, and found a nice simple jquery solution, and figured someone else might find it helpful if nothing else:

with header being the div, and originalLeft being, well, the initial left:position. This also works if someone scrolls and then zooms out, such that it would go where you would want it to.



回答2:

You need javascript. Here you can read a tutorial (with mootools): http://www.rickyh.co.uk/css-position-x-and-position-y/. Here a similar question, solved with jquery: CSS: fixed position on x-axis but not y?



回答3:

you can do it by css itself:

<div style="width:250px; height:250px; border:solid;overflow:scroll; overflow-y:hidden">     <div style="width:500px; height:500px; border:solid;"></div> </div> 


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