Web Platform Atlas
EN⚡RUUA⚡DE⚡FR⚡ES⚡PL⚡PT⚡ZH⚡JA⚡
Каталог / CSS Display Module Level 3 / Display Order: the order property

3 Display Order: the order property

Статический предпросмотр (RU): для MDN, WPT, глоссария и BYOK-перевода откройте интерактивный Атлас.
⚡ Открыть главу в Атласе

3. Display Order: the order property

Имя:

order

Значение:

<integer>

Начальное значение:

0

Применяется к:

flex items and grid items

Наследуется:

нет

Проценты:

н/д

Вычисленное значение:

specified integer

Канонический порядок:

согласно грамматике

Тип анимации:

by computed value type

Boxes are generally displayed and laid out in the same order as they appear in the source document. In some formatting contexts, the order property can be used to rearrange the order of boxes to deliberately create a divergence of the logical order of elements and their spatial arrangement on the 2D visual canvas. (See § 3.1 Reordering and Accessibility.)

Specifically, the order property controls the order in which flex items or grid items appear within their container, by assigning them to ordinal groups. It takes a single <integer> value, which specifies which ordinal group the item belongs to.

Here’s an example of a catalog item card which has a title, a photo, and a description. Within each entry, the source document content is ordered logically with the title first, followed by the description and the photo. This provides a sensible ordering for speech rendering and in non-CSS browsers. For a more compelling visual presentation, however, order is used to pull the image up from later in the content to the top of the card.

article.sale-item { display: flex; flex-flow: column; } article.sale-item > img { order: -1; /* Shift image before other content (in layout order) */ align-self: center; }

<article class="sale-item"> <h3>Computer Starter Kit</h3> <p>This is the best computer money can buy, if you don’t have much money. <ul> <li>Computer <li>Monitor <li>Keyboard <li>Mouse </ul> <img src="images/computer.jpg" alt="You get: a white desktop computer with matching peripherals." width="250" height="188"> </article>