CSS3 Flexbox: Flex-Direction: Row-Reverse

The flex-direction property specifies the direction of the flexible items inside the flex container. The default value of flex-direction is row (left-to-right, top-to-bottom). The following example shows the result of using the row-reverse value:

HTML file: Displayed by browser:
<style>
.flex-container {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row-reverse;
    flex-direction: row-reverse;
    width: 400px;
    height: 250px;
    background-color: lightgrey;
}
.flex-item {
    background-color: cornflowerblue;
    width: 100px;
    height: 100px;
    margin: 10px;
}
</style>
<body>
<div class="flex-container">
    <div class="flex-item">flex item 1</div>
    <div class="flex-item">flex item 2</div>
    <div class="flex-item">flex item 3</div>
</div>
<p>The flex items are rendered in reverse with Item 1 at the right.</p>
</body>
flex item 1
flex item 2
flex item 3

The flex items are rendered in reverse with Item 1 at the right.

With the way we used this flex-direction: row-reverse; property, only the contents of the flex-container are affected. On the previous page, when we had applied the right-to-left directional change, the container was also affected.

Back button Table of Contents Next button