问题
I have figured out how to center the logo, but cannot get the navigation to center as well. Hopefully you guys can help!
Code for centering logo:
#header #logo{
float: none !important;
}
#header hgroup {
float: none !important;
text-align: center !important;
}
I know this is pretty basic, but I would love some help. Thank you. See my website here.
回答1:
This should do it:
#navigation{
float:none;
text-align:center;
}
#navigation > ul{
float:none !important;
display:inline-block;
}
回答2:
You can use text-align: center
on the <nav>
tag and display: inline-block
to the <ul>
.
You also need remove float: right
from #header #navigation
and #header #navigation ul.nav
.
You also don't need #header #navigation
, as ids are unique #navigation
should be enough.
#navigation {
float: none;
text-align: center;
}
#navigation ul.nav {
display: inline-block;
float: none;
}
来源:https://stackoverflow.com/questions/22722693/center-menu-navigation