<div id="header"></div>
<div id="sticky"></div>
<div id="section"></div>
<div id="footer"></div>
<style>
body { margin: 0px; background-color: #e3e3e3; }
#header { background-color: #cb5454; height: 140px; }
#sticky { background-color: #546bcb; height: 70px; }
#section { height: 1500px; }
#footer { background-color: #cb5454; height: 140px; }
</style>
这里是我的代码:http://jsfiddle.net/uaqh018d/在滚动过另一个div后,让div粘到页面顶部?
我想#sticky坚持到页面顶部滚动过去的#header后。 我也想隐藏它直到卡住。然后,当滚动回到#header之后,它当然会再次不粘标签。
我怎样才能做到这一点?
谢谢!我相信这样会更有效率! – John 2014-10-30 22:01:30
什么是高度是动态的而不是已知的? – SearchForKnowledge 2015-01-16 21:43:48
@SearchForKnowledge你的意思是粘头的高度? http://jsfiddle.net/uaqh018d/40/ – bowheart 2015-01-17 15:46:38