Have a Navbar <div>
, inside is a <ul>
and each <li>
contains a <a>
with a link (this is for a navigation bar)
I looked on google and this site and i couldnt find exactly what i was looking for.
What i want is to be able to keep my current style (using <li>
with <a>
's inside) and i want the <li>
to be evenly distributed and centered (this part comes naturally if they are evenly distributed...) inside the <ul>
(which is inside the navbar <div>
).
Anyways if that doesnt make sense let me know, currently they are just left aligned...Heres what i have:
HTML:
<div class="navbar">
<ul>
<li><a href="Home">Home</a></li>
<li><a href="Discounts">Discounts</a></li>
<li><a href="Contact">Contact Us</a></li>
<li><a href="About">About Us</a></li>
</ul>
</div>
CSS:
.navbar {
width: 100%;
margin-left: auto ;
margin-right: auto ;
background-color: #ABCDEF;
}
.navbar ul {
list-style-type: none; /*to remove bullets*/
text-align: center;
margin: 0px;
padding: 0px;
width: 90%;
overflow: hidden;
}
.navbar li{
float: left;
padding: 2px;
width: 150px;
margin-left: auto ;
margin-right: auto ;
}
I can also include my .navbar a{} if that is neccesary. I am very new to CSS so go easy, also I did look all over SO and Google first and couldnt find anything quite like this (Although maybe since I am new i dont realize its the same).
If this is a faulty CSS method and/or there is a much easier, more commonly used way of doing this. Go ahead and link/post that instead, but i would prefer this way as it makes most sense to me.
Thanks