Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我找到了如何使用 jQuery 修复 div 位置。
这是一个例子。
我可以使用 css 达到相同的效果吗?
UPD:我见过这个解决方案。如果固定元素不适合窗口,我还希望出现水平窗口滚动条。
您可以在没有酷炫的刘海和动画的情况下实现相同的效果position: fixed。固定元素将随之滚动。
position: fixed
至于内容不适合窗口时的水平滚动条,只需为固定元素定义width: 100%and overflow-x: scroll。
width: 100%
overflow-x: scroll