Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I change an inner div to fixed after I scroll to the bottom of it?
    primarykey
    data
    text
    <p>I have a div within a div and I want to make inner div absolute but upon scroll to the bottom it changes to a fixed div. Its a side bar right now, I want it to scroll with the middle until it is at the bottom of the div and then have it become fixed.</p> <p>Any idea?</p> <p>I tried messing with this code but I can't seem to figure it out: </p> <pre><code> &lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2'&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { var offset = $("#right_side_bar").offset(); var topPadding = 15; $(window).scroll(function() { if ($(window).scrollTop() &gt; offset.top) { document.getElementById("#right_side_bar").style.position = 'fixed'; } else { }; }); }); &lt;/script&gt; </code></pre> <p>Image: <a href="http://i.stack.imgur.com/S2Nbi.png" rel="nofollow">http://i.stack.imgur.com/S2Nbi.png</a></p> <p>So the above code doesn't work but here is a further explanation of the issue. I have a huge div called container. Then a right sidebar called "right_side_bar. The right_side_bar has more content than is showing so I want it to scroll with the container, but as soon as all of the content is shown in the right_side_bar (meaning the user has scrolled to the bottom) then I want it to stop scrolling with the page and just become fixed. If the scroll goes back to the top, then it should become absolute again. Let me know if this makes sense!</p> <p><a href="http://i.stack.imgur.com/S2Nbi.png" rel="nofollow">http://i.stack.imgur.com/S2Nbi.png</a></p> <pre><code> #right_side_bar{ position:absolute; margin-top:38px; width:272px; margin-left:722px; background-color:#FFF; /* D6E6F7 */ height:100%; overflow:scroll; z-index: 0; } #container{ width: 994px; /*height: 885px;*/ background-color: #D6E6F7; font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; /*padding-bottom: 30px;*/ } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload