Add Flexbox margins in a grid - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex

Description

Add Flexbox margins in a grid

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>Flexbox border confusion</title> 
  <style>
.dashboard {<!--  ww w . j  a  v a  2  s .  c o  m-->
   height:501px;
}

.my {
   flex:2 2 auto;
   position:relative;
   display:flex;
}

.my--panel {
   margin:6px;
}

.my--horizontal, .my--vertical {
   display:flex;
}

.my--vertical {
   flex-direction:column;
}

.my__component {
   flex:2 2 auto;
}
</style> 
 </head> 
 <body translate="no"> 
  <div class="my my--horizontal dashboard dashboard--none"> 
   <div class="my my--vertical" style="flex-basis: 50%;"> 
    <div class="my my--panel" style="flex-basis: calc(50% - 10px);"> 
     <div class="my__component" style="background-color: rgb(240, 179, 117);"></div> 
    </div> 
    <div class="my my--panel" style="flex-basis: calc(50% - 10px);"> 
     <div class="my__component" style="background-color: rgb(240, 117, 117);">
       hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. hello there, i am a longer text. 
     </div> 
    </div> 
   </div> 
   <div class="my my--vertical" style="flex-basis: 50%;"> 
    <div class="my my--vertical" style="flex-basis: 50%;"> 
     <div class="my my--panel" style="flex-basis: calc(50% - 10px);"> 
      <div class="my__component" style="background-color: rgb(179, 240, 117);"></div> 
     </div> 
     <div class="my my--panel" style="flex-basis: calc(50% - 10px);"> 
      <div class="my__component" style="background-color: rgb(240, 117, 240);"></div> 
     </div> 
    </div> 
    <div class="my my--panel" style="flex-basis: calc(50% - 10px);"> 
     <div class="my__component" style="background-color: rgb(117, 179, 240);">
       hello there, i am a smaller text. 
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials