Vertically align list items inside div - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:UL Alignment

Description

Vertically align list items inside 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">
#HomeRight {<!--  ww w . j ava2s  . c  o m-->
   position:absolute;
   width:121px;
   top:121px;
   bottom:100px;
   right:0;
}

#HomeRight ul {
   margin:0;
   padding:0;
   height:100%;
   display:table;
}

#HomeRight li {
   list-style:none;
   width:121px;
   height:26%;
   text-align:center;
   vertical-align:middle;
   background-color:Chartreuse;
   border:2px solid yellow;
   background-clip:padding-box;
}

#HomeRight li:before {
   content:'';
   display:inline-block;
   width:2px;
   vertical-align:middle;
   height:100%;
}
</style> 
 </head> 
 <body> 
  <div id="HomeRight"> 
   <ul> 
    <li>L</li> 
    <li>L</li> 
    <li>L</li> 
    <li>L</li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials