html - Verticaly aligning nav bar with css -


i making website fun , put in navigation bar. problem navigation bar not vertically centred , being pushed down row links leaving unwanted white space between logo , nav bar. links high causing them (when hovering over) not remain within navigation area. there fix this? code below:

html:

<nav id="nav">     <ul>         <li><a href="http://www.google.com">hello</a></li>         <li><a href="http://www.google.com">hello</a></li>     </ul>        </nav> 

css:

.container{  width:1020px;  margin:auto;  position:relative;  }       #nav{ width:1020px; height:50px; background-color:#ebb035; } #nav ul{ display:block; list-style-type:none; } #nav li{ display:inline; } #nav a:link{ color: #000000; font-weight: 700; padding: 8px; text-align: center; text-decoration: none; text-transform: uppercase; } #nav a:visited{ color: #000000; font-weight: 700; padding: 8px; text-align: center; text-decoration: none; text-transform: uppercase; } #nav a:hover{ background-color:#ffcc00; color: #000000; font-weight: 700; padding: 8px; text-align: center; text-decoration: none; text-transform: uppercase; } 

thank in advance!

add positioning #nav , #nav ul follows; , you'll have result like this

#nav {     width:1020px;     height:50px;     background-color:#ebb035;     position: absolute; } #nav ul {     display:block;     position: relative;     list-style-type:none;     margin-top: 1em; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -