0

I have 2 parallel divs, when page is scrolled and a specific div reaches its end I need to stop it from scrolling but continue scrolling for the other div. For better example see this website left Div How it Sticks

2 Answers2

0

Try something like this. Basically whenever the page is scrolling, this will check where you are in the page and you can make a toggle based on that. I'd recommend once you get to that point on the screen to do an (element you want fixed).addClass()

Community
  • 1
  • 1
Joey Wood
  • 273
  • 1
  • 10
0

you can do it like this.refer the working demo.

<!DOCTYPE html>
<html>
<head>
 <title></title>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
 
</head>

<style type="text/css">
.left{
    width: 200px;
    height: 200px;
    background-color: orange;
    position: fixed;
    left: 0;
    top: 0;

}

.right{
    width: 400px;
    height: 1500px;
    background-color: gray;
    position: absolute;
    right: 0;
    top: 0;

}

.right h1{
    position: absolute;
    bottom: 0;
}


</style>


<body>

<div class="left">I am the left div</div>
<div class="right">I am the right div

<h1>bottom</h1>
</div>



<script type="text/javascript">


</script>




</body>


</html>
caldera.sac
  • 4,918
  • 7
  • 37
  • 69