On May 27, 10:45 pm, Boris Zbarsky <[email protected]> wrote:
> Emanuele D'Arrigo wrote:
> > I guess as long as flexboxes can be contained in a
> > cssboxes and viceversa we can all be pretty happy campers. =) I wonder
> > if that's already possible...
>
> Yes, of course.  You can do it in Gecko and Webkit.

But not in standard webpages or xul files? I'll have to look into
webkit. I'm not familiar with it.

> > Can you give me a simple example of flexboxes where height and width
> > interdependent?
>
> Sure.  Any hbox that contains a CSS block has a height that depends on
> the width it gives that block.  At the same time, its width depends on
> the widths of its kids, which might depend on the heights of its kids,
> which have to end up equal to its height, no?

Oooooh! Gotcha! I understand.

> This is why the flexbox layout algorithm ends up with a loop you keep
> doing over and over until the numbers converge (or until you end up with
> too many iterations).

Whoa. Nasty. This means there is no certain, analytical solution to
the constraints. I'm actually surprised that this made into the
standards.

In the meantime, I tried to write down a simplified version of the
algorithm to a) handle the width of an hbox (and by analogy a vbox)
and b) allow for percentages. Could you tell me what do you think
about it?

-----
Assuming an hbox and a set of children boxes. For simplicity both
parent and children have no padding, borders or margins.

If the specified -width- of the box is set to "auto", its preferred
width will be the sum
of the preferred widths of the children. This value is then clamped to
be between minwidth
and maxwidth.

If the specified width is a non-percentage length (px, em, mm), that
is the preferred width of the box.
If the specified width is set as a percentage, either the parent's
width is -not- auto or
- at least one of the siblings's width must -not- be a percentage AND
- the sum of the widths expressed as percentages must be less than
100%

This allows us to use the following equations to calculate how wide 1%
is in pixels and
consequently calculate the widths expressed as percentages:

onePctInPixels = 100 - sum(percentages) / sum
(lenghtsConvertedToPixels)
widthInPixels = widthInPercentage * onePctInPixels

=?

Manu

_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to