Reputation: 13206
I am making a nav
bar for my site. In I want the nav
bar to have horizontally centered li
items, except I wan the middle item to be an h1
that is preferably not part of the list. (This is to keep nav
items specific to navigation, not the title of the page.
Right now my HTML looks like this (I am using icon-fonts btw):
<nav class="nav">
<h1>Page title</h1>
<ul>
<li><span data-icon=""></span><h2>HOME</h2></li>
<li><span data-icon=""></span><h2>ABOUT</h2></li>
<li><span data-icon=""></span><h2>CONTACT</h2></li>
</ul>
</nav>
And my css is this:
nav {
background: gray;
text-align: center;
}
nav li:first-child {
display: inline-block;
float: left;
}
nav li {
float: right
}
The output looks like this:
No matter what I try I can not get the h1 on the same line. Note that I do not want to just insert a p
element as the second item on the list. Any help would be great.
Upvotes: 1
Views: 444
Reputation: 7067
I think adding this will help:
nav { position: relative; }
nav h1 { position: absolute; top: 0; width: 100%; }
Upvotes: 1