Aligning a div vertically - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div

Description

Aligning a div vertically

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <style type="text/css">
.wrapper{<!--  w w  w  . j  a  va  2 s. c  om-->
   overflow: hidden;
   border: 1px solid blue;
   width: 400px;
   position:relative; background:yellow
}
.left{
   border: 1px solid red;
   max-width: 200px;
   max-height: 50px;
   overflow: hidden;
   position:absolute;
   top:50%; margin-top:-25px
}
img{
   display: block;
}
.right{
   width: 200px;
   height: 200px;
   border: 1px solid green;   float:right
}

      </style> 
   </head> 
   <body> 
      <div class="wrapper"> 
         <div class="left"> 
            <h1> 
               <a href="#"> 
                  <img src="http://java2s.com/resources/f.png" alt="alt message"> 
               </a> 
            </h1> 
         </div> 
         <div class="right">
             Right 
         </div> 
      </div>  
   </body>
</html>

Related Tutorials