Control Item order in flexbox container - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Item

Description

Control Item order in flexbox container

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

.container {<!--   w w w. j  av  a2 s  .  co m-->
   display: flex;
   flex-direction: row;
   justify-content: space-between;
   background-color: lightblue;
   width: 100%;
   padding: .5rem;
   box-sizing: border-box;
}
.name {
   background-color: white;
   padding: 1rem;
   margin: .25rem;
   flex-basis: 40px
}
.options {
   display: flex;
   flex-direction: row;
}
.option {
   background-color: white;
   padding: 1rem;
   margin: .25rem;
   flex-basis: 80px;
}
.action {
   background-color: white;
   padding: 1rem;
   margin: .25rem;
}
@media (max-width: 350px){
   .options  {
      order: 1; flex-basis: 100%;
   }
   .container {
      flex-wrap: wrap;
   }
}


      </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="name">
     Lorem ipsum 
   </div> 
   <div class="options"> 
    <div class="option">
      2 
    </div> 
    <div class="option">
      3 
    </div> 
    <div class="option">
      4 
    </div> 
   </div> 
   <div class="action">
     5 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials