Float one item to the left while centering a second in flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Center

Description

Float one item to the left while centering a second 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">

.top_bar {
   text-align: center;
   border: 1px solid black;
   padding: 10px;
   height: 80px;
   width: 300px
}

.a {<!--from  w  w w.j  av a  2 s.  c  o  m-->
   float: left;
   border: 1px solid yellow;
   width: 20px;
   height: 30px
}

.b {
   border: 1px solid red;
   width: 50px;
   height: 30px;
   margin: auto
}

      </style> 
 </head> 
 <body> 
  <div class="top_bar"> 
   <div class="a">
     hi 
   </div> 
   <div class="b">
     yo 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials