-
Notifications
You must be signed in to change notification settings - Fork 711
[css-align] justify-items
and anonymous block boxes
#11461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
But how would you allow aligning 'anonymous blocks' to the end if that's the desired behavior? |
There is of course a trade-off, we need to think which option will be less confusing. |
That's beside the point since we're no longer dealing with anonymous block boxes in that case. I think keeping the |
I don't think most authors know about anonymous block boxes, and we typically pretend that they aren't there (see percentage resolution, #2595, etc.) So I think we should either
|
When you add |
The big difference is that grid and flex formatting contexts create an anonymous box around each text run. Block formatting contexts only create an anonymous box when there is a mix of inline-level and block-level contents. So saying that anonymous boxes can always be aligned is still not be enough for <div style="width: 200px; justify-items: right; border: solid">foo</div> |
I see, sure. I guess then I'm suggesting that a box should be generated in this case, in order to have consistency. Though I'll admit I don't fully know the side-effects of that. |
I might be missing something, but I think the use of According to 6.1. Inline-Axis (or Main-Axis) Self-Alignment: the justify-self property, |
Yes, that's the current situation, but it seems bad to me. Hence the 2 options I proposed in #11461 (comment): either prevent Note in the 2nd option <!DOCTYPE html>
<div style="justify-items: center; text-align: left; border: solid; width: 200px">
lorem ipsum<br>sit amet
</div> (avoiding the need to add an inner wrapper to get this effect) |
I don't follow. Per the spec:
In particular, the text in How does introducing an anonymous block box here align with the rules for inline formatting contexts? Are you proposing that
I suppose in cases where there are multiple lines of different lengths (e.g., due to a But that feels like a confusing corner case. The box is anonymous, unstyleable, and auto-sized, so people expect no room for alignment to matter. I think discarding alignment properties like |
I'm not proposing to blockify anything.
Yes, the 2nd option avoids establishing an inline formatting context on block containers with
I'm not sure if you are arguing for no change, or for my 1st proposed option. |
Option: "Current" |
IMO The current behaviour in Blink is a bug, and I'd prefer "Option 1" |
But "Option 1" is not compatible with the scenario described in #11461 (comment) |
IMO The current behaviour in Blink is undesirable, and I'd prefer "Option 2". As a web author, I always prefer the more control option. |
I agree that:
|
How is the anonymous block in option 2 sized? |
Yes, both the current Blink behavior and option 2 raise some questions about that. So from an implementation point of view I prefer option 1, which is what I implemented in Servo (I didn't have to do anything special, I just got this behavior due to how we implement anonymous block boxes). Presumably the anonymous box would be sized as <!DOCTYPE html>
<style>
div { float: left; width: 100px; height: 100px;justify-items: right; border: solid; margin: 1em }
div::before { content: ""; display: block }
span { display: inline-block; border: solid magenta }
</style>
<div> <span style="width: 100%; height: 100%"></span> </div>
<div> <span style="width: stretch; height: stretch"></span> </div> So Blink breaks the axis symmetry by allowing percentages and |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
IMO, option 2 feels like a hack. |
Also, I don’t think whether the current Blink behavior is a bug is a matter of opinion but rather it’s a question of whether it conforms to the specification, which it does. While
So it should come as no surprise that an anonymous block box in Blink derives its default value from Similarly, consider how the |
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <[email protected]> Commit-Queue: Ian Kilpatrick <[email protected]> Cr-Commit-Position: refs/heads/main@{#1455957}
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <[email protected]> Commit-Queue: Ian Kilpatrick <[email protected]> Cr-Commit-Position: refs/heads/main@{#1455957}
See: w3c/csswg-drafts#11461 Our current behaviour is (IMO) a bug, so tentatively change it to "Option 1" in the issue. Adds a tentative test as well. Change-Id: I145d39d819347d3446dd08cdd98e055e40625b53 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6512658 Reviewed-by: David Grogan <[email protected]> Commit-Queue: Ian Kilpatrick <[email protected]> Cr-Commit-Position: refs/heads/main@{#1455957}
In Blink it looks like this:
In the 1st case, there is no block-level child to align. In the 2nd case, "foo" gets wrapped inside an anonymous block, which is then aligned by
justify-items: right
.But it seems potentially unexpected that appending a block affects the alignment of the inline contents.
Maybe anonymous blocks should get assigned
justify-self: start
justify-self: stretch
(ornormal
)?The text was updated successfully, but these errors were encountered: