Open MatsPalmgren opened 4 years ago
Note that (https://drafts.csswg.org/css-cascade/#computed)
The computed value exists even when the property does not apply
Since the condition only checks the computed value, it seems that align-content
doesn't need to apply in order to let images participate in baseline alignment... but if the property has some effect then it should apply.
@MatsPalmgren Content alignment requires adding space inside the element, but replaced elements don't have internal CSS layout. So I'm unsure how they could be participating?
Certainly they can participate in self-alignment, but that's a different thing.
Added "non-replaced" to the description of when baseline alignment applies, so at least there's no confusion on the image grid item case.
Content alignment requires adding space inside the element, but replaced elements don't have internal CSS layout. So I'm unsure how they could be participating?
First, talking about elements in this context makes no sense, since CSS layout is based on boxes. Second, "adding space" here refers to increasing the padding and images certainly have padding, for example:
<img style="border:1px solid; padding:30px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAMCAIAAAD3UuoiAAAAGklEQVQoz2Nk%2BP%2BfgRqAiYFKYNSgUYOGp0EA%2BQMCFrJdTgsAAAAASUVORK5CYII%3D">
So why exactly shouldn't align-content:baseline
apply to images (and any other box type that applies padding
) by increasing that padding?
So what you're asking, is not about baseline alignment specifically, but to have align-content
and justify-content
, in general, apply to replaced elements, correct?
I will note that replaced elements do already have the object-fit
and object-position
properties applying to them...
Huh, I... did not realize that padding worked on images. Makes sense, I guess, since padding is outside the content area.
So what you're asking, is not about baseline alignment specifically, but to have align-content and justify-content, in general, apply to replaced elements, correct?
That does appear to be it, yes.
I will note that replaced elements do already have the object-fit and object-position properties applying to them...
I think there's a reasonable interaction here - object- properties still just size/align the content within the content box, but the -content properties would effectively apply "magic padding" to align the content box as specified. normal
would resolve to stretch
for replaced elements, meaning no magic padding.
The CSS Working Group just discussed css-align] Apply align-content to replaced elements #4545
.
@MatsPalmgren CSSWG discussed your suggestion (see above), but we didn't see any strong use cases. So for the moment, it doesn't seem worth the implementation and testing effort to make this work. If there are significant use cases you have, or others have, we're open to considering them, though.
The spec for align-content says:
An image is not a block container, nor any of the other containers listed.
So, per those definitions,
align-content:baseline
does not apply to an<img>
grid item.However, the spec for Baseline Content-Alignment says for Grid items:
A strict reading of the spec implies that Baseline Content-Alignment does not apply to an
<img>
grid item since thealign-content
property doesn't even apply to images. Is this is the intention of the spec? I see no particular reason why images, for example, shouldn't be allowed to participate in baseline alignment usingalign-content:baseline
.