W3C home > Mailing lists > Public > www-style@w3.org > May 2010

Re: [css-flexbox] Computation Algorithm

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 11 May 2010 21:14:59 +1200
Message-ID: <AANLkTinKEDLzFzQ8KpK4Kvcm0LDyYG1X604jD4NBYPS-@mail.gmail.com>
To: Andrew Fedoniouk <news@terrainformatica.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style@w3.org
On Tue, May 11, 2010 at 7:23 PM, Andrew Fedoniouk <news@terrainformatica.com
> wrote:

>   That is where my CSS intuition fails. What would be that "preferred
> width" in terms of CSS?
> We have declared, used, computed...
>

Preferred width is basically the same as the intrinsic width.

 It appears as min-intrinsic width is misteriusly involved in your preferred
> width calculations.
> But how is it in principle related to flexes?
>
> ElementA: "AAAAAAAA"
>  ElementB: "BBBB BBBB BBBB BBBB"
>
> Why preferred width of elementA should be larger than of elementB?
>

It's not.


>
>
>
> 2) if the preferred widths add up to less than the width of the container,
> the leftover width is allocated to the children in proportion to their
> box-flex values
> 3) if the preferred widths add up to more than the width of the container,
> the excess width is taken away from the children in proportion to their
> box-flex values
> I don't think this is difficult for authors to understand.
>
>
>
> That is quite diferent from XUL flex definition:
> https://developer.mozilla.org/en/XUL/Attribute/flex
> no?
>

No. "Elements with larger flex values will be made larger than elements with
lower flex values, at the ratio determined by the two elements." --- that's
my point 2.

 Anyway web designer first question: how to make one element twice wider
> than another?
> Does your FlexBox have an answer on this?
>

Yes. You set the min-width to something very small, like 0.1px, to override
the default min-width, and set 'width' to 0. (min-width:0 is treated as
auto, because 0 is the initial value of min-width ... this is really ugly, I
agree.) E.g.

  <div style="display:-moz-box;">
    <div style="width:0; min-width:.1px; -moz-box-flex:1;
background:yellow;">HelloHelloHello</div>
    <div style="width:0; min-width:.1px; -moz-box-flex:2;
background:lime;">HelloHelloHello</div>
  </div>

Personally I think using 'width' to set the "preferred" width and possibly
ending up with a width that doesn't match the value of 'width' is a bad
design. If we can use calc() to mix flex units with preferred widths so that
'width' actually sets the width, that would be better, I think. It would be
cool if authors could write
    width:calc(200px + 2fl);
or
    width:calc(max-content + 2fl);
or
    width:calc(min-content + 2fl);
or
    width:2fl;

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]
Received on Tuesday, 11 May 2010 09:15:32 GMT

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