Scale items when resizing in flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex

Description

Scale items when resizing in flexbox

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">
main {<!--from w w  w  . j  av a 2 s.c  o  m-->
   display:flex;
   flex-direction:column;
   width:100%;
}

.example-a,
.example-b {
   display:flex;
   border:3px solid Chartreuse;
   align-items:center;
   justify-content:center;
}

.example-a ol,
.example-b ol {
   list-style-type:none;
   display:flex;
   align-items:center;
   margin:0;
   padding:0;
   width:100%;
}

.example-a ol .cell,
.example-b ol .cell {
   border:2px solid yellow;
   width:100px;
   height:100px;
   align-items:center;
   justify-content:center;
}

.example-a .spacer,
.example-b .spacer {
   width:201px;
   height:21px;
   background-color:blue;
}

.example-a .spacer:first-child,
.example-b .spacer:first-child {
   width:401px;
}

.example-b ol {
   background-color:pink;
   padding:11px;
   border-radius:11px;
   max-width:401px;
   width:41%;
}

section+section {
   margin-top:21px;
}
</style> 
 </head> 
 <body> 
  <main> 
   <section class="example-a"> 
    <ol> 
     <li class="spacer"></li> 
     <li class="cell">A</li> 
     <li class="cell">B</li> 
     <li class="cell">D</li> 
     <li class="cell">D</li> 
     <li class="spacer"></li> 
    </ol> 
   </section> 
   <section class="example-b"> 
    <span class="spacer"></span> 
    <ol> 
     <li class="cell"> <span>A</span> </li> 
     <li class="cell"> <span>B</span> </li> 
     <li class="cell"> <span>C</span> </li> 
     <li class="cell"> <span>D</span> </li> 
    </ol> 
    <span class="spacer"></span> 
   </section> 
  </main>  
 </body>
</html>

Related Tutorials