Topic: JS StickyContent - not fixed after reload
Volodymyr Yatsynych pro asked 8 years ago
$(".sticky").sticky({
topSpacing: 118,
zIndex: 2,
stopper: "bottom"
});
Scroll page. Reload page. Sticky element no fixed on position until not scroll page.
If hack use auto scroll +/- 1px;
var $htmlPos = $('html').scrollTop();
$('html').scrollTop($htmlPos + 1);
$('html').scrollTop($htmlPos);
What a good solution to this?
Adrian Sawicki answered 8 years ago
position: fixed
all the time. You can get such effect by doing it this way:
$(function() {
$(".test").sticky({
topSpacing: 0,
zIndex: 2,
stopper: "bottom"
});
}
});
and add class to your sticky content for example:
<div class="sticky position">
<h2>Sticky Element</h2>
...
</div>
.position {
position: fixed;
top: 118px;
}
Regards,
Adrian FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No