Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
am trying to use one scroll bar for two div. it tried the below coding
HTML
<div class="container">
<div class="col1" >
Mycontent 1
</div>
<div class="col2" >
Mycontent 2
</div>
</div>

CSS
.container {
    height: 300px;
    width: 35%;
    overflow-x: hidden;
    overflow-y: scroll;
    position: relative;
    padding-bottom: 30px;   
}

.col1 {
    height: 500px;
    width: 300px;
     position: relative;
    float: left;
}

.col2 {
    height: 500px;
    width: 300px;   
   position: relative;
   float:right;
}


this is working but i want to use col1 scroll bar for col2 without creating third div can any one please help me to do this.
Posted
Updated 9-Aug-12 2:18am
v2
Comments
AshishChaudha 9-Aug-12 7:52am    
All what you have to join CSS for .Container and .coll and put col2 inside coll.

HTML
<div class="col2"  önscroll="OnScroll(this)">
Mycontent 1
</div>

by calling the below javascript function i achived this
JavaScript
function OnScroll(div) {
    var d1 = document.getElementById("col1");
    d1.scrollTop = div.scrollTop;
}
 
Share this answer
 
v2
try to do something in ONSCROLL event in javascript.
 
Share this answer
 
Comments
kevin_ze 9-Aug-12 9:23am    
thanks yaar for remembering onscroll event. using that event only i have solved my problem.my vote is 5 for u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900