Center menu navigation [closed]

廉价感情. 提交于 2020-01-06 13:08:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!