Is there a way to prevent the div with the class fixed
from staying fixed at the bottom after scrolling over it?
I stumbled upon a solution thanks to the comments below.
This is my current JavaScript code:
var element = $(".below");
window.onscroll = function(ev) {
var a = element.position();
if (a.top <= window.scrollY + window.innerHeight) {
$("fixed").css('position', 'static');
} else{
$("fixed").css('position', 'fixed');
}
};
This is my current HTML markup:
<header>
</header>
<section>
Some html and text here here
</section>
<section class="fixed" style="position: fixed; width: 100%; bottom: 0;">
text
</section>
<section class="below">
</section>
<footer>
</footer>
Is there a better way to achieve this?