W3C home > Mailing lists > Public > www-style@w3.org > November 2012

Re: Alternative to Sticky Positioning

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 7 Nov 2012 09:34:19 -0800
Message-ID: <CAAWBYDB=A3C7X7=p6EQmbn9D8FMAcJjRh3rn3oPNW59s+L2MZQ@mail.gmail.com>
To: Rudolph Gottesheim <r.gottesheim@loot.at>
Cc: www-style list <www-style@w3.org>
On Wed, Nov 7, 2012 at 7:19 AM, Rudolph Gottesheim <r.gottesheim@loot.at> wrote:
> I've got an alternative idea for the problem that Sticky Positioning[1] is
> trying to solve. I think it can potentially solve more use cases than just
> this one.
> What if we had a pseudo-class that matched elements based on whether they
> are inside the viewport or not? Then you could give the element a position:
> fixed when it is not. Like this:
> [role=navigation]:viewport-partially-hidden {
>     position: fixed;
>     top: 0;
>     left: 0;
> }
> Obviously, I'm bad in naming pseudo-classes, but you get the gist.
> It could also take an argument, like which part of the element is hidden (to
> stick something to the top/bottom of the viewport).
> What do you think?

Unfortunately, this suffers from basic circularity problems - your
pseudoclass applies when an element is outside of the viewport, but
then applies rules that put it back in the airport, so the pseudoclass
no longer applies, so it goes out of the viewport, so the pseudoclass

It also doesn't address the use-case quite right.  This pseudoclass
would apply when the page first loaded, if the element was below the
fold, and after the element's container scrolled off the top of the
screen, if it was sticky to its container rather than the viewport.

Finally, because your idea switches it to fixpos, which takes it out
of the normal flow, the content surrounding it would jump around when
it switched.  Stickypos is basically "magical relpos", where it still
takes up space in the flow.

Received on Wednesday, 7 November 2012 17:35:06 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:23 UTC