Wrap the flex items in reverse order with CSS


Use the flex-wrap property with wrap-reverse value to wrap flex-items in reverse order.

Example

You can try to run the following code to implement the wrap-reverse value

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: #D35400;
            flex-wrap: wrap-reverse;
         }
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            width: 100px;
            margin: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Quiz</h1>
      <div class = "mycontainer">
         <div>Ans1</div>
         <div>Ans2</div>
         <div>Ans3</div>
         <div>Ans4</div>
         <div>Ans5</div>
         <div>Ans6</div>
         <div>Ans7</div>
         <div>Ans8</div>
         <div>Ans9</div>
      </div>
   </body>
</html>

Updated on: 06-Jul-2020

972 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements