Centering ul in block-element vertically - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:UL Element

Description

Centering ul in block-element vertically

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">
.cf:before, .cf:after {<!--   w  w w .  ja v a2 s  .co  m-->
   content:" ";
   display:table;
}

.cf:after {
   clear:both;
}

ul {
   margin:0;
   padding:0;
   list-style:none;
   background:red;
}

nav {
   background:grey;
   text-align:center;
}

nav ul {
   font-size:0px;
   text-align:right;
}

nav li {
   font-size:15px;
   display:inline;
}

nav li a {
   display:inline-block;
   width:auto;
   background:green;
}

.logo {
   font-size:34px;
   background:orange;
   float:left;
}

nav {
   display:table;
   width:100%;
}

ul {
   display:table-cell;
   vertical-align:middle;
   height:100%;
   width:100%;
}
</style> 
 </head> 
 <body> 
  <nav class="cf"> 
   <div class="logo"> 
    <a href="#">Lore</a> 
   </div> 
   <ul> 
    <li> <a href="#">Lorem </a> </li> 
    <li> <a href="#">Lorem </a> </li> 
    <li> <a href="#">Lorem </a> </li> 
   </ul> 
  </nav>  
 </body>
</html>

Related Tutorials