Dowemo
0 0 0 0

1. Side positioning generally we can use position: fixed; but sometimes not, such as I need the div that I need to scroll is positioned inside the whole, if it's relative to the entire screen, as follows:

It's a viewleftshare, and ct is just one of the many div.

<div id="ct" style="height: 3000px;width: 100%;position: relative;">
 <div id="viewleftshare" style="width: 200px;height: 360px;background: gold;position: absolute;left: 0;top: 100px;"></div>
 <div style="width: 500px;float: left;margin-left: 220px;">
 <p>111111111111111</p>
 </div>
</div> 

2. We can use js to dynamically make the div that you want to scroll.
<script type="text/javascript"> 
window.onscroll=function(){ 
 var ct=document.getElementById("ct"); 
 var oDiv=document.getElementById("viewleftshare"); 
 var height=ct.offsetHeight;
 var top = document.body.scrollTop;
 console.log(height - top)
 if(height - top <= 450){
 oDiv.style.top = height - 450 +'px';
 }else{
 oDiv.style.top = top + 100 +'px';
 } 
} 
</script> 
3. If you want to animate, you can:
#viewleftshare{transition: all ease 0.5s;}





Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs