OK. Thank you for giving me your precious time to look over this problem.
Basically, I have a “div” which I use at the top of the screen for my navigation bar. It’s a simple navigation bar, just a 80% wide “div” with some text that changes color on hover.
The problem that I’m having is; the text automatically starts at the top of the “div” and I’d like to center it. I’ve tried margins, paddings, floats, “div’s” inside “div’s” etc. etc.
I will post the code here for the navigation bar and if you happen to know how to fix it can you please let me know?
Thanks
HTML CODE:
<div class="header">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Repairs</a></li>
<li><a href="#">Tune up/ Viruses</a></li>
<li><a href="#">System Builds</a></li>
<li><a href="#">Cables</a></li>
<li><a href="#">Contact us</a></li>
<li><a href="#">Find us</a></li>
<li><a href="#">Links</a></li>
<!-- <li><a href="/"><img src="facebook.png"></a></li> -->
</ul>
</div>
CSS CODE:
.header ul { margin:0px;}
div.header
{
width: 80%;
height: 40px;
margin-top: none;
margin-bottom: none;
margin-left: auto;
margin-right: auto;
border-top: none;
border-left: none;
border-right: none;
border-bottom: none;
background-color: #575757;
}
li
{
display: inline;
font-family: 'open sans,' arial;
padding-right: 10px;
padding-top: 10px;
margin-left: 10px;
font-size: 20px;
}
li a
{
text-decoration: none;
color: white;
}
li a:hover
{
color: #00ccff;
}
You can use a bunch of things to vertically center an element.
The best one for one line elements (elements with just one line of text, for example) is
line-heightSet the
line-heightto be equal the height of its parent: