Vertically center menu within variable height header - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Menu

Description

Vertically center menu within variable height header

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolor </title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
body {<!--from w  w  w .  j ava2 s.co  m-->
   margin:0;
}

header {
   background-color:Chartreuse;
   padding:2em;
   position:fixed;
   top:0;
   left:0;
   right:0;
}

.brand {
   float:right;
}

nav {
   margin:auto 0;
   position:absolute;
   top:0;
   bottom:0;
   width:100px;
   height:41px;
}

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

li {
   display:inline-block;
   margin-right:0.26em;
}

a {
   background-color:yellow;
   color:blue;
   padding:5px 9px;
   text-decoration:none;
}

.cf:before,
.cf:after {
   content:" ";
   display:table;
}

.cf:after {
   clear:both;
}
</style> 
 </head> 
 <body> 
  <header class="cf"> 
   <div class="brand"> 
    <img src="https://www.java2s.com/style/demo/Firefox.png"> 
   </div> 
   <nav> 
    <ul> 
     <li> <a href="#">Lore</a> </li> 
     <li> <a href="#">Lore</a> </li> 
     <li> <a href="#">Lore</a> </li> 
     <li> <a href="#">Lore</a> </li> 
    </ul> 
   </nav> 
  </header>  
 </body>
</html>

Related Tutorials