Vertically align a div with fixed positioning - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

Vertically align a div with fixed positioning

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">
#parent {<!--from  ww w.  j a  v a2 s.  c o  m-->
   background-color:Chartreuse;
   color:yellow;
   width:100%;
   padding:11px;
   display:table;
}

#text {
   width:81%;
   display:table-cell;
}

#hideMessage {
   display:table-cell;
   color:blue;
   cursor:pointer;
   vertical-align:middle;
   text-align:center;
}

#hello {
   background-color:pink;
   padding:6px 11px;
}
</style> 
 </head> 
 <body> 
  <div id="parent"> 
   <div id="text"> 
    <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, vitae venenatis diam imperdiet vel. Donec tortor diam, pretium vitae nibh vitae, consectetur lacinia sem. Proin luctus facilisis volutpat. Ut semper s</span> 
    <a>Lore</a> 
   </div> 
   <div id="hideMessage"> 
    <span id="hello">Lorem ipsum do<span></span> </span> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials