3
Is there any way to center the logo of this example without using two lists?
In the example website, it uses two lists to keep the logo in the center, how can I put the logo inside a "li" without affecting the menu structure?
3
Is there any way to center the logo of this example without using two lists?
In the example website, it uses two lists to keep the logo in the center, how can I put the logo inside a "li" without affecting the menu structure?
3
You can insert the image into one of the <li>
and then use position
and top
to adjust the position of this element.
As you yourself suggested having a specific class in that element is useful. So the HTML would be:
<div class="nav">
<ul>
<li><a href="">Link 1</a></li>
<li><a href="">Link 2</a></li>
<li class="logo"><a href=""><img src="/favicon.png"/></a></li>
<li><a href="">Link 3</a></li>
<li><a href="">Link 4</a></li>
</ul>
</div>
and the important CSS:
.nav ul li{
float: left;
}
.logo {
position: relative;
top: -10px;
}
1
I set an example in Codepen http://codepen.io/guidiego/pen/ZGxZbj using Bootstrap and SCSS, but I leave some alerts:
I would use Nav-pills to space the last li of the first part (:Nth-Child(2)) and leave the logo outside the LI, the only reason is responsiveness, it is difficult to treat the menu when it has an element that does not belong to it!
The form addressed is also not the best, I particularly only use position:BSOLUTE on extreme issues!
Anyway it’s the code and the hint :)
Hugs
Browser other questions tagged html css
You are not signed in. Login or sign up in order to post.
What do you mean two lists? You want to have the logo in the middle of
<li>
from one menu? Can you describe better what we should look for on the other site?– Sergio
note that on the other site there are two <ul> for a single menu, which is not efficient. <ul> logo <ul>. I’m looking for a better way to do the same thing, without using two <ul> and putting the logo inside a <li>. The best way I’ve found so far is this http://stanhub.com/how-to-center-a-logo-in-unordered-list-navigation-using-css3-nth-child-selector/
– Daniel
I don’t quite understand the problem. It seems simple. Can you explain from this example? -> http://jsfiddle.net/y9jLte8s/
– Sergio
http://jsfiddle.net/y9jLte8s/1/ ?
– Daniel
I’m not sure I understand what you want... do you want to get the image lower? like this -> http://jsfiddle.net/y9jLte8s/2/ ?
– Sergio
that’s right!! Now how I remove the space that’s left on top?
– Daniel
http://jsfiddle.net/y9jLte8s/4/ <-
– Sergio
@Sergio excellent, creates a response.
– Jorge B.