English 中文(简体)
Flexbox - Flex-Order
  • 时间:2024-09-17

Flexbox - Flex-Order


Previous Page Next Page  

The flex-order property is used to define the order of the flexbox item.

The following example demonstrates the order property. Here we are creating six colored boxes with the labels one, two, three, four, five, six, arranged in the same order, and we are reordering them in the order one, two, five, six, three, four, using the flex-order property.

<!doctype html>
<html lang = "en">
   <style>
      .box{
         font-size:35px;
         padding:15px;
      }
      .box1{background:green;}
      .box2{background:blue;}
      .box3{background:red; order:1}
      .box4{background:magenta; order:2}
      .box5{background:yellow;}
      .box6{background:pink;}
      
      .container{
         display:inpne-flex;
         border:3px sopd black;
         flex-direction:rows;
         flex-wrap:wrap;
      }
   </style>
   
   <body>
      <span class = "container">
         <span class = "box box1">One</span>
         <span class = "box box2">two</span>
         <span class = "box box3">three</span>
         <span class = "box box4">four</span>
         <span class = "box box5">five</span>
         <span class = "box box6">six</span>
      </span>
   </body>
</html>

It will produce the following result −