Set the flex items vertically from bottom to top with CSS

Use the flex-direction property with column-reverse value to set the flex items vertically from bottom to top. This reverses the normal column direction, making items stack from the bottom upward.

Syntax

.container {
    display: flex;
    flex-direction: column-reverse;
}

Example

The following example demonstrates how to arrange flex items vertically from bottom to top using column-reverse

<!DOCTYPE html>
<html>
<head>
<style>
    .mycontainer {
        display: flex;
        flex-direction: column-reverse;
        background-color: orange;
        padding: 10px;
        width: 120px;
    }
    .mycontainer > div {
        background-color: white;
        text-align: center;
        line-height: 40px;
        font-size: 25px;
        width: 100px;
        margin: 5px 0;
        border: 1px solid #ccc;
    }
</style>
</head>
<body>
    <h2>Quiz Questions</h2>
    <div class="mycontainer">
        <div>Q1</div>
        <div>Q2</div>
        <div>Q3</div>
        <div>Q4</div>
        <div>Q5</div>
        <div>Q6</div>
    </div>
</body>
</html>
An orange container displays quiz questions stacked vertically from bottom to top: Q6 at the bottom, then Q5, Q4, Q3, Q2, and Q1 at the top. Each question appears in a white box with a border.

Conclusion

The flex-direction: column-reverse property is perfect for reversing the vertical order of flex items. This creates a bottom-to-top layout while maintaining the benefits of flexbox.

Updated on: 2026-03-15T13:21:38+05:30

828 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements