Aligning elements inside absolutely positioned div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Aligning elements inside absolutely positioned div

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">
.menu {<!--  w  ww  .  j  av  a 2s. co  m-->
   width:301px;
   height:100%;
   position:absolute;
   left:0px;
   top:0px;
   z-index:11;
   background:Chartreuse;
}

.icon-block {
   width:51px;
   height:51px;
   display:inline-block;
   background-color:yellow;
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-repeat:no-repeat;
}

.text-block {
   float:right;
   width:231px;
   height:51px;
   display:inline-block;
   background:blue;
}

.a-block {
   display:block;
}
</style> 
 </head> 
 <body> 
  <div class="menu"> 
   <a href="#" class=""> 
    <div class="icon-block"> 
     <!-- VOID BLOCK, BACKGROUND IMAGE --> 
    </div> 
    <div class="text-block"> 
     <span>Home</span> 
    </div> </a> 
   <div class="icon-block"> 
    <!-- VOID BLOCK, BACKGROUND IMAGE --> 
   </div> 
   <div class="text-block"> 
    <a href="#" class="a-block"> About </a> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials