Open rreno opened 2 years ago
WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=243882
I'm in support of removing any effect of the -content properties on positioned elements. -content is a property controlling the container's layout; positioned elements don't lay out in the container in the first place. While the static position of a positioned element is meant to reflect, to a reasonable extent, "where the element would lay out if it wasn't positioned", in flexbox we already break from that a decent bit and instead pretend it's a lone element (as flexbox layout is too interdependent to actually do such hypothetical layout).
We've also tried to break more from this dependent model in Position, and anything in support of that would be good. We've delayed on editting Flexbox's definition of staticpos until we had a better idea of the compat impact of the Alignment/Position changes, but if we're making this break official (and tested) we should get all the verbiage aligned.
I've just added a use-counter for removing Blink's current justify-content logic which affects the static position. We'll have some data in a month or two.
Ian
I'm in support of removing any effect of the *-content properties on positioned elements
Seems like this should be doable for align-content
at least, since AFAIK it already has no effect on positioned flex children in Blink/WebKit. I'm fine making this change in Firefox, if we've got agreement on it and ideally some spec text. It's kind of unfortunate (particularly with the current & maybe long-term asymmetry of align-self
vs. justify-content
), but it's where we are, I guess.
RE hypothetically fixing that asymmetry and ignoring justify-content
: I like this idea in theory (i.e. I like the idea of fully switching to only respect align-self
/ justify-self
for aligning the staticpos of abspos flex children), but I'm a bit skeptical that it'll be web-compatible in the justify
axis, given that:
a) all browsers currently respect justify-content
for these children (and we'd need to stop doing that)
b) no browsers currently respect justify-self
for these children (and you're proposing we start doing that)
Having said that: if IanK's use-counters prove it to be shippable without breaking the web, it'd be a pretty trivial change for us, implementation-wise, and I'd be happy to make that change as long as we're not the only ones to do so. :)
Agree with @tabatkins comment https://github.com/w3c/csswg-drafts/issues/7596#issuecomment-1217068116 and would be glad to make this change which brings static positioning in flexbox more in alignment with other layout models.
@rreno I have one question, earlier you wrote:
The spec for
align-content: stretch
statesLines stretch to take up the remaining space. If the leftover free-space is negative, this value is identical to flex-start. Otherwise, the free-space is split equally between all of the lines, increasing their cross size.
All browsers currently ignore the second sentence.
Were you referring here to the behavior of abspos elements or of in-flow elements? Because browsers certainly follow that sentence for in-flow content, afacit.
@fantasai
Were you referring here to the behavior of abspos elements or of in-flow elements? Because browsers certainly follow that sentence for in-flow content, afacit.
Yes, this issue is specific to abspos elements.
The CSS Working Group just discussed [css-flexbox] align-content: stretch for abspos children of flex containers should align with browser behavior.
, and agreed to the following:
RESOLVED: ignore the effect of align-content properties on absolutely positioned elements in flex
RESOLVED: open an issue on justify-content
New issue for justify-content: https://github.com/w3c/csswg-drafts/issues/7644
ignore the effect of align-content properties on absolutely positioned elements in flex
I think Gecko is the only engine that needs to change in response to this resolution. I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1786910 on making that change.
@rreno FYI, I'll update WPT expectations as part of that change.
Thank you @dholbert !
I actually landed a patch in WebKit to match Gecko's behavior (I wasn't anticipating a resolution so quickly) so I'll work to get that reverted.
https://drafts.csswg.org/css-flexbox/#align-content-property
Summary
The behavior of Blink, Gecko, and WebKit with respect to
align-content: stretch
when computing the static position of absolutely-positioned children of flex containers is the same whether the flex container has negative available space or not. This is in contrast to the spec text which specifies fallback behavior toflex-start
when there is negative remaining space in the container. I am proposing that we amend the spec to align with the current behavior of browsers forstretch
since it is thenormal
value foralign-content
and any change is risky for web compatibility.Details
The static position of absolutely-positioned children of flex containers is determined as if they were the sole flex item in the container. In the case of a multi-line flex container,
align-content
is used to align flex lines within the container. When the container has available space,align-content: stretch
will cause flex lines to fill the container. When the available space in the flex container is negative (the simplest, hand-wavy example is a child that is larger than the flex container)align-content: stretch
is specified to fall back to be the same asflex-start
. However, the behavior of all major browser engines is that the flex line fills the flex container whether available space is positive or negative. This is reflected in Web Platform Tests such as https://wpt.fyi/results/css/css-flexbox/abspos/flex-abspos-staticpos-align-content-005.htmlThe spec for
align-content: stretch
statesAll browsers currently ignore the second sentence. This is somewhat of an accident in WebKit as we actually ignore
align-content
entirely, which is what I was working to resolve when I came across this disagreement between the spec and browser behavior.The problem, as I see it, is that all browsers do not respect the fallback behavior for
align-content: stretch
when statically positioning abspos children andstretch
is the default behavior. A change to match the spec in browser engines is risky for web compatibility as authors who leavealign-content
unspecified would have their content positioned differently than it is currently. @dholbert provided a great example illustrating surprising behavior when following the current spec.I propose the spec is amended to remove the fallback behavior to
flex-start
for absolutely positioned children and to specify behavior as is currently implemented.