Div的margin-top在滚动时保持20px [英] Div's margin-top stays 20px when scrolling

查看:427
本文介绍了Div的margin-top在滚动时保持20px的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望此页面右侧的div在向下滚动时停止向上滚动页。所以它总是从窗口的顶部20px,客户可以读它的内容。

I want the div on the right side of this page to stop scrolling up when you scroll down the page. So that it is always 20px from the top of the window and the customer can read it's contents.

如何实现呢? CSS? jQuery?

How can I achieve that? CSS? jQuery?

谢谢

推荐答案

执行滚动事件,当滚动高度过去某个点时,使div位置:fixed。

jQuery. Do an on scroll event, and when scroll height gets past a certain point, make the div position:fixed.

这篇关于Div的margin-top在滚动时保持20px的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆