ngSticky icon indicating copy to clipboard operation
ngSticky copied to clipboard

Can't use on header element

Open RongBranovate opened this issue 8 years ago • 5 comments

I used the sticky attribute on a <header> element but it won't stick. If i use it on the inner <div> element it will stick but without the wrapping header, that way I lose the header element style, so everything looks different. any idea why this is happening and how can it be solved?

RongBranovate avatar Apr 16 '16 12:04 RongBranovate

Just ran into the same issue. It appears because sticky makes calculations on an element's offset from the top of the page.

I shrunk my header and moved it down further to force an offset.

chris480 avatar May 02 '16 18:05 chris480

I see... Would you mind adding an example?

Thanks!

RongBranovate avatar May 02 '16 18:05 RongBranovate

header {
 margin-top:1px
}

I also tried .1px and it still works.

chris480 avatar May 02 '16 18:05 chris480

@chris480 Adding this causes the header to push the entire body downwards at the start of the scroll - leaving a white blank space when i scroll.... maybe is it because my header is transparent?

RongBranovate avatar May 17 '16 12:05 RongBranovate

Ok, so i gave it a different background-color when it sticks and now its not white

RongBranovate avatar May 17 '16 14:05 RongBranovate