Tiny Frontend Logo
Posts 0116

On This Page

Ordering Flexible Elements

In many cases, we rely on the flex-direction property to manage the display order of flexible items.

In addition to this powerful property, we will explore another feature that enables precise control over the order of individual elements within the flex container

The order Property!

What is the "order" Property?

The CSS order property determines the order of a flexible item relative to other flexible items inside the same container.

Syntax

.item-element {
    order: <integer>;
    order: 10;
}

Learn from Demo

Consider the following three blocks (A, B, C) displayed in a row:

Implementing this layout is straightforward using the following HTML snippet:

<div style="display: flex">
    <div class="block-a">A</div>
    <div class="block-b">B</div>
    <div class="block-c">C</div>
</div>

Changing the Order

Suppose we want to move Block B to the last slot:

We can achieve this by simply setting the order property for Block B:

.block-b {
    order: 3
}

The final display will be as desired.

Subscribe to read the full content

* Free subscribe to enjoy full content access.
* You can cancel anytime with 1-click.

Read Next

0115

JavaScript: Page Location

Whether you're a seasoned developer or just starting your journey, understanding how to manipulate the web page's location through JavaScript can be a very useful tool in your arsenal.

JavaScript: Page Location
0114

Cookies

As a frontend developer, understanding how cookies work is essential for building robust web applications. In this article, we'll explore the world of browser cookies, demystify their mechanics, and learn how to harness their power in your projects.

0113

JavaScript: Local Storage

Understanding how to store data on the client side is essential for creating robust web applications. In this article, we'll explore local storage, one of the key mechanisms for caching data within the user's browser. Let's dive in!

0112

JavaScript: Session Storage

As a frontend developer, understanding how to store data on the client side is crucial. In this article, we’ll delve into the world of web storage, specifically focusing on session storage. Let’s explore what it is, how it works, and when to use it.

JavaScript: Session Storage
0110

Cross-Origin Resource Sharing (CORS)

Please imagine you're building a spiffy weather application using JavaScript and you want to display live weather data from a popular weather service.

Cross-Origin Resource Sharing (CORS)
0109

Cross-Site Scripting (XSS) in JavaScript

Cross-Site Scripting (XSS) is a web security vulnerability that allows an attacker to inject malicious code into a web page that is viewed by other users.

Cross-Site Scripting (XSS) in JavaScript