leafo/sticky-kit

position static / relativ is important to sticky objects!

Opened this issue · 5 comments

I spend two hours for this problem to solve…

i was wondering why the sticky object did not stick (bottom:0) to the parent div properly. instead, it jumped back to the top of the element. i found out that the "placeholder" div had position:relative instead of position:static like in your examples. And it drove me crazy where the static came from. Now i know it! When your sticky element has "position:relative" by default (which is the case if you are dealing with bootstrap columns), then the placeholder div got also this property. And then it will not stick at the bottom of your parent element. So so solve this, simply add position:static as a default css value to your sticky element! jesus… please add this hint to the docs!

nicmare, you saved my life!
position:static worked like a charm, thank you!

Me too stucked with this for 2 hours. Don't know how I found this issue. But thank you!

And I think this can be considered as a bug because placeholder with relative position just doesn't work as expected. It should forced to be static.

Thanks for the ring on the clue phone. Change line 70 to

if (spacer) {
    spacer.css('position', 'static');
}

Agree with xak2000.

Here is my solution.

#31 (comment)

Duplicate of #31