I'm trying to make it so when you load a page a div is sticking to the bottom of it. Then when a user scrolls down it sticks to the top.
I can do the stick to the top part using a sticky element.
<div id="container">
<div id="menu">
? ??<ul>
? ? ? ??<li><a href='#test'>Line 1</a></li>
? ? ? ??<li><a href='#'>Line 2</a></li>
? ? ? ??<li><a href='#'>Line 3</a></li>
? ??</ul>
</div>
</div>
<script type="text/javascript">
? ??$(document).ready(function(){
? ? ? ??$(window).scroll(function(){
? ? ? ? ? ?if($(this).scrollTop()>=660)
? ? ? ? ? ?{
? ? ? ? ? ?$('#menu').addClass('fixed');
? ? ? ? ? ?}else{
? ? ? ? ? ? ? ?$('#menu').removeClass('fixed');
? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ?});
? ??});
? ??</script>
I just can't do it so it sticks to the bottom on load. I've attached a little mockup if it's unclear.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…