W3C home > Mailing lists > Public > www-style@w3.org > October 2014

Re: [css-grid] Sizing of grid item elements

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 16 Oct 2014 15:43:10 -0700
Message-ID: <CAAWBYDCdhP-d+QYtb6c4eDP7iLpsZRbVDb5KT1tJ01vk=8s1fw@mail.gmail.com>
To: Manuel Rego Casasnovas <rego@igalia.com>
Cc: www-style list <www-style@w3.org>
On Thu, Oct 16, 2014 at 2:46 PM, Manuel Rego Casasnovas <rego@igalia.com> wrote:
> On 22/08/14 17:08, Emil Björklund wrote:
>>>> The second thing that struck me as counter-intuitive is that columns
>>> sized
>>>> with percentages on a grid container without an explicitly declared width
>>>> won't get sizes according to a percentage of the grid container width,
>>> but
>>>> compute to "auto" width. In my example, I used the <body> element as the
>>>> grid container, and wanted empty "spacer" columns on the side of the
>>> actual
>>>> contents, but they collapsed (to nothing, as they had no items/content).
>>> I
>>>> had to set "width: 100%" on the <body> element for them to get rendered,
>>>> which felt superflous.
>>>
>>> I suspect another bug.  Percentages generally are able to resolve
>>> against a "fill" width on blocks; there's no good reason they
>>> shouldn't work as you expect here.  (In some cases they can't resolve,
>>> when the size of the element depends on the size of the content, but
>>> that's not the case for widths in "block" contexts by default.)
>>>
>>
>> Good to know, I'll make sure to file that one.
>
> I was taking a look to this bug [1] and I think that current behavior
> matches the spec [2]:
> "If the inline or block size of the grid container is indefinite,
> <percentage> values relative to that size are treated as 'auto'"
>
> In that case we're talking about a "grid container without an explicitly
> declared width" which seems indefinite.
> So, current behavior would be right, and you would need to set the width
> of the grid container to get the expected behavior.
>
> Am I missing something?

"auto" is not always indefinite; in particular, in block contexts,
width:auto is definite as long as its containing block is definite,
since it's filling its containing block.  You can use "width: 50%;" on
a display:block element whose parent is "width:auto", and grids are
defined to auto-size the same as a block container.

So a width:auto grid container has a definite width in all the same
situations that a width:auto block container does, and columns with
percentage sizes should be resolveable in the same cases that a block
child with a percentage width is resolveable.

~TJ
Received on Thursday, 16 October 2014 22:43:58 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:25 UTC