sticky-kit icon indicating copy to clipboard operation
sticky-kit copied to clipboard

position static / relativ is important to sticky objects!

Open nicmare opened this issue 9 years ago • 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 avatar Apr 14 '16 17:04 nicmare

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

vadbard avatar Apr 23 '16 20:04 vadbard

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.

xak2000 avatar May 03 '16 12:05 xak2000

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

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

Agree with xak2000.

rogerlos avatar Jun 19 '16 23:06 rogerlos

Here is my solution.

https://github.com/leafo/sticky-kit/issues/31#issuecomment-253387736

chaegumi avatar Oct 13 '16 01:10 chaegumi

Duplicate of #31

hadley avatar Oct 28 '16 15:10 hadley