Skip to main content

Position

Enum Position 

Source
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

Source

pub fn is_out_of_flow(self) -> bool

Returns true if this position takes the item out of normal flow (Absolute or Fixed)

Source

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)

Trait Implementations§

Source§

impl Clone for Position

Source§

fn clone(&self) -> Position

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Position

Source§

impl Debug for Position

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Position

Source§

fn default() -> Position

Returns the “default value” for a type. Read more
Source§

impl Eq for Position

Source§

impl PartialEq for Position

Source§

fn eq(&self, other: &Position) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Position

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.