website/docs/advanced/containing-block.md
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import Playground from '@site/src/components/Playground';
Often times certain properties depend on a node beyond the
one it is applied to. An example of this is percentage lengths like width: 50% which
will set the width of a node to 50% of some other length. That other length is determined
by the size of the containing block. A containing block is not a Yoga-specific
concept and exists in the web,
but since Yoga only implements a subset of web browser capabilities the behavior of
containing blocks is much more streamlined and it is helpful to frame it differently.
YGNodeSetAlwaysFormsContainingBlock(node, true /*alwaysFormsContainingBlock*/);
availableWidth and availableHeight that is passed in to the call to
CalculateLayout.<Playground code={<Layout config={{useWebDefaults: false}}> <Node style={{ width: 200, height: 200, padding: 10 }}> <Node style={{ height: 100, width: 100, position: 'static' }}> <Node style={{ height: 25, width: '50%', bottom: 10, position: 'absolute' }} /> </Node> </Node> </Layout>} />