Same width for child elements of flex items - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Width

Description

Same width for child elements of flex items

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 a v a2s .  c  om-->
   display: flex; 
   height: 100px; 
   border: 1px solid red; 
}
.item {
   display: flex; 
   justify-content: center; 
   flex: 1; 
   border: 1px solid gray; 
   margin: 2px;  
}
.item:nth-child(2) {
   flex-direction: column; 
   flex-grow: 2; 
   text-align: center; 
   border: none;  
   margin: 0; 
}
.item2 {
   flex: 1; 
   border: 1px solid gray;
   margin: 2px;
}
.container-inner2 {
   display: flex; 
   flex: 1;  
}
.item3 {
   flex: 1; 
   border: 1px solid gray;
   margin: 2px;
}


      </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="item">
     azerty (.item) 
   </div> 
   <div class="item"> 
    <div class="item2">
      azerty (.item2) 
    </div> 
    <div class="container-inner2"> 
     <div class="item3">
       azerty (.item3) 
     </div> 
     <div class="item3">
       azerty (.item3) 
     </div> 
    </div> 
   </div> 
   <div class="item">
     azerty (.item) 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials