2018-02-13 03:50:31 -08:00
|
|
|
---
|
2018-02-19 02:55:30 -08:00
|
|
|
path: "/docs/absolute-relative-layout"
|
2018-02-15 06:12:21 -08:00
|
|
|
title: "Absolute/Relative Layout"
|
2018-02-13 03:50:31 -08:00
|
|
|
hasPlayground: true
|
|
|
|
---
|
2018-02-15 06:12:21 -08:00
|
|
|
## Absolute/Relative Layout
|
2018-02-13 03:50:31 -08:00
|
|
|
|
2018-02-16 06:41:54 -08:00
|
|
|
The `position type` of an element defines how it is
|
|
|
|
positioned within its parent.
|
2018-02-15 06:12:21 -08:00
|
|
|
|
2018-02-16 06:41:54 -08:00
|
|
|
**RELATIVE (DEFAULT)** By default an element is positioned
|
|
|
|
relatively. This means an element is positioned according to the
|
|
|
|
normal flow of the layout, and then offset relative to that position
|
|
|
|
based on the values of `top`, `right`, `bottom`, and `left`.
|
|
|
|
The offset does not affect the position of any sibling or parent elements.
|
2018-02-15 06:12:21 -08:00
|
|
|
|
2018-02-16 06:41:54 -08:00
|
|
|
**ABSOLUTE** When positioned absolutely an element doesn't take
|
2022-10-04 13:59:32 -07:00
|
|
|
part in the normal layout flow. It is instead laid out independent
|
2018-02-16 06:41:54 -08:00
|
|
|
of its siblings. The position is determined based on the
|
2022-10-04 13:59:32 -07:00
|
|
|
`top`, `right`, `bottom`, and `left` values.
|
2018-02-14 07:53:07 -08:00
|
|
|
|
|
|
|
<controls prop="positionType"></controls>
|
|
|
|
|
2018-02-16 06:41:54 -08:00
|
|
|
The position values `top`, `right`, `bottom`, and `left` behave
|
|
|
|
differently depending on the `position type` of the element. For
|
|
|
|
a `relative` element they offset the position of the element in the
|
|
|
|
direction specified. For `absolute` element though these properties
|
|
|
|
specify the offset of the element's side from the same side on the parent.
|
2018-02-15 06:12:21 -08:00
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
<controls prop="position"></controls>
|