I am working on a project that involves creating a scrollable div with "title" elements inside. I want the title element of each section to stick to the top of the div as I scroll, similar to how a menu sticks to the top of a webpage. An example of this can be seen in the Mac OS X calendar's "Day" view.
I have found a solution for making the element stick, but I need help figuring out how to detect when a title element reaches the top of the scrollable div.
Here is the scenario:
<div class="container">
<div class="floatLeft">
<div class="scrollingDiv" style="height:100px; overflow-y:scroll; overflow-x:hidden;">
<ul>
<li>
<div>
<h4>Title</h4>
<div>Content</div>
</div>
</li>
<li>
<div>
<h4>Title</h4>
<div>Content</div>
</div>
</li>
</ul>
</div>
</div>
<div class="floatRight"></div>
</div>
Is there a way to determine when the second "Title" reaches the top of the "scrollingDiv", not the top of the entire page?
Any assistance would be greatly appreciated!