Css vertically centering a fixed positioning div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

Css vertically centering a fixed positioning 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">
#lightbox {<!--   w  ww. ja va2s  . com-->
   display:table-cell;
   vertical-align:middle;
   position:fixed;
   width:100%;
   text-align:center;
   z-index:601;
   cursor:pointer;
   left:0;
   top:100px;
}

#image {
   position:relative;
   height:100px;
   border:2px solid Chartreuse;
}
</style> 
 </head> 
 <body> 
  <div id="lightbox"> 
   <img id="image" src="https://www.java2s.com/style/demo/Firefox.png"> 
  </div>  
 </body>
</html>

Related Tutorials