The closest thing to a formula is just the algorithm in the spec:
http://www.w3.org/TR/css3-flexbox/#resolve-flexible-lengths
I don't think it can easily be described in a formula. You can cover easy cases with a formula, but it gets a bit more complex (and requires multiple loops of the algorithm) when elements have min-width
or max-width
constraints.
SIDE NOTE: the flexbox spec will likely soon make a small change to flex-grow
and flex-shrink
behavior, so that they're treated more like a percentage when their sum is less than 1. (So e.g. flex-grow: 0.1
would never give you more than 10% of the free space, even if you're the only child.) That proposal is described here: http://lists.w3.org/Archives/Public/www-style/2013Oct/0246.html