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

Re: [css3-flexbox] flex-align: stretch on <img>

From: Anton Prowse <prowse@moonhenge.net>
Date: Thu, 26 Apr 2012 13:40:00 +0200
Message-ID: <4F993410.9000704@moonhenge.net>
To: www-style@w3.org
CC: "Tab Atkins Jr." <jackalmage@gmail.com>, fantasai <fantasai.lists@inkedblade.net>
On 26/04/2012 00:38, Tab Atkins Jr. wrote:
> On Wed, Apr 25, 2012 at 2:11 PM, fantasai<fantasai.lists@inkedblade.net>  wrote:
>> On 04/25/2012 02:02 PM, Daniel Holbert wrote:
>>>
>>> I think just ran across a simple case where "flex-item-align:stretch"
>>> (the default behavior) is somewhat problematic.
>>>
>>> Consider this example (where "photo.jpg" is a 50px-by-50px image):
>>>
>>>   <div style="display: flexbox; width: 100px; height: 100px">
>>>     <img src="photo.jpg"/>
>>>   </div>
>>>
>>> The<img>    has an intrinsic height and width, which the author presumably
>>> wants to use, since he hasn't specified any other width or height there.
>>>
>>> However, since the<img>    has "height: auto" and effectively
>>> "flex-item-align:stretch" (default values), the flexbox spec says we
>>> need to force the<img>'s height property to resolve to 100px:
>>
>>
>> I think that's fine. This is what the author asked for; perhaps
>> he is using the image in a way that stretching makes sense. Or
>> perhaps he's set object-fit: contain; on it. As you say, this
>> can be easily turned off with e.g.
>>   img { flex-item-align: center; }
>
> The author didn't *really* ask for this, though - it's just a default
> behavior that's kinda confusing.
>
> In fact, this is a potentially issue for *all* replaced elements,
> since they all have intrinsic sizing that we usually expect they'll
> adhere to.
>
> However, working around it, while still allowing the author to stretch
> these things when they want to, would require an additional magic
> value for the initial value.  (We can't use "auto", because that's
> already used to mean "compute to what my parent says is my default".)
> I'm not sure that's worth it.

What's the motivation for 'stretch' being the default?  It wouldn't seem 
to work well with typical toolbars, which are one of the primary use 
cases for this spec.

Cheers,
Anton Prowse
http://dev.moonhenge.net
Received on Thursday, 26 April 2012 11:41:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:52 GMT