pub enum Position {
Static,
Relative,
Absolute,
Fixed,
Sticky,
}Expand description
The positioning strategy for this item.
This controls both how the origin is determined for the Style::position field,
and whether or not the item will be controlled by flexbox’s layout algorithm.
WARNING: this enum follows the behavior of CSS’s position property,
which can be unintuitive.
Position::Static is the default value, matching the default behavior in CSS.
Variants§
Static
The item is laid out in normal flow. inset has no effect on statically positioned items,
and they do not act as a containing block for absolutely positioned descendants.
Relative
The item is laid out in normal flow, then the inset offset is applied as a correction factor.
Offsets do not affect the position of any other items.
Relatively positioned items act as a containing block for absolutely positioned descendants.
Absolute
The item is taken out of normal flow and positioned relative to its closest positioned ancestor (its containing block), if any. Otherwise, it is placed relative to the root. No space is created for the item in the page layout, and its size will not be altered.
WARNING: to opt-out of layouting entirely, you must use Display::None instead on your Style object.
Fixed
The item is taken out of normal flow and positioned relative to the root (viewport), unless an ancestor overrides containing-block behavior (e.g. via transforms in a full CSS implementation).
Sticky
The item is laid out in normal flow exactly like a statically positioned item: inset is not applied
as an offset (in CSS, sticky insets are scroll thresholds, which Taffy has no knowledge of; applying the
sticky offset is the responsibility of the caller once it knows the scroll position).
Like Relative, a sticky item acts as a containing block for absolutely positioned descendants.
Implementations§
Source§impl Position
impl Position
Sourcepub fn is_out_of_flow(self) -> bool
pub fn is_out_of_flow(self) -> bool
Returns true if this position takes the item out of normal flow (Absolute or Fixed)
Sourcepub fn is_positioned(self) -> bool
pub fn is_positioned(self) -> bool
Returns true if this position causes the item to act as a containing block
for absolutely positioned descendants (any value other than Static)