I have a header div that is fixed to the top of the browser window at 100% width. Within the header div there is a div with title text and there is a div with a horizontal list. The horizontal list div should appear to the right of the title text div.
Here is my CSS and HTML:
#header {
position:fixed;
top:0;
left:0;
right:0;
background-color:#333333;
padding:20px;
}
#title {
float:left;
color:#000000;
font-size:30px;
margin-right:24px;
background-color:#ffffff;
padding:8px;
}
#navigation ul {
padding:0;
margin:0;
list-style-type:none;
}
#navigation ul li {
display:inline;
margin-right:20px;
padding:3px;
background-color:#ffffff;
}
#navigation ul li a {
color:#000000;
text-decoration:none;
}
<div id="header">
<div id="title">Some Title Text</div>
<div id="navigation"><ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul></div>
</div>
So right now the title and navigation divs are left aligned inside the header div. How can I horizontally center the title and navigation divs?
Edit: Would prefer a solution that doesn't use a hardcoded width(eg. width: 500px
) since the list size isn't always the same.