Aligning three elements to left center and right inside a container - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Parent Container

Description

Aligning three elements to left center and right inside a container

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Full Width Banner</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
#header-blue {<!--from  w  w w  .  ja  va 2  s  .c  om-->
   margin-bottom:51px;
   background-color:Chartreuse;
   color:yellow;
}

#header-wrap {
   display:flex;
   align-items:flex-start;
   justify-content:space-between;
   text-align:center;
   padding:2rem 0;
}

.header-left {
   border:2px solid blue;
   width:100px;
}

.header-right {
   border:2px solid pink;
   width:100px;
}

.header-center {
   border:2px solid WhiteSmoke;
   width:100px;
}

#header-blue:last-child>#header-wrap::after {
   content:"";
   width:100px;
}
</style> 
 </head> 
 <body> 
  <section id="header-blue"> 
   <div id="header-wrap"> 
    <div class="header-left"> 
     <p>1</p> 
    </div> 
    <div class="header-center"> 
     <p>2</p> 
     <p>2</p> 
     <p>2</p> 
     <p>2</p> 
    </div> 
    <div class="header-right"> 
     <p>3</p> 
     <p>3</p> 
    </div> 
   </div> 
  </section> 
  <section id="header-blue"> 
   <div id="header-wrap"> 
    <div class="header-left"> 
     <p>1</p> 
    </div> 
    <div class="header-center"> 
     <p>2</p> 
     <p>2</p> 
     <p>2</p> 
     <p>2</p> 
    </div> 
   </div> 
  </section>  
 </body>
</html>

Related Tutorials