pub fn percent<T>(value: T) -> Valwhere
T: ValNum,
Expand description
Returns a Val::Percent
representing a percentage of the parent node’s length
along a specific axis.
If the UI node has no parent, the percentage is based on the window’s length along that axis.
Axis rules:
- For
flex_basis
, the percentage is relative to the main-axis length determined by theflex_direction
. - For
gap
,min_size
,size
, andmax_size
:width
is relative to the parent’s width.height
is relative to the parent’s height.
- For
margin
,padding
, andborder
values: the percentage is relative to the parent’s width. - For positions,
left
andright
are relative to the parent’s width, whilebottom
andtop
are relative to the parent’s height.