Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Role of CSS flex-direction property row-reverse value
The CSS flex-direction property with the row-reverse value arranges flex items horizontally from right to left. This is the opposite of the default row behavior, which flows from left to right.
Syntax
selector {
display: flex;
flex-direction: row-reverse;
}
Example
The following example demonstrates how flex-direction: row-reverse reverses the horizontal order of flex items −
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
flex-direction: row-reverse;
background-color: orange;
padding: 10px;
}
.mycontainer > div {
background-color: white;
text-align: center;
line-height: 40px;
font-size: 25px;
width: 100px;
margin: 5px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<h1>Quiz</h1>
<div class="mycontainer">
<div>Q1</div>
<div>Q2</div>
<div>Q3</div>
<div>Q4</div>
<div>Q5</div>
<div>Q6</div>
</div>
</body>
</html>
The output of the above code is −
A heading "Quiz" appears followed by an orange container with six white boxes labeled Q1-Q6. The boxes are arranged horizontally but in reverse order: Q6, Q5, Q4, Q3, Q2, Q1 (from left to right).
Conclusion
The flex-direction: row-reverse value is useful when you need to display flex items in reverse horizontal order. This maintains the horizontal layout while reversing the visual sequence of elements.
Advertisements
