Centering a css dropdown menu

你离开我真会死。 提交于 2019-12-01 13:37:50

Since you are using float, the only way to center it is to apply a width to the containing element and use margin-left: auto; margin-right: auto. There is no way to do this will retaining the flexible width.

An alternative to float would be display:inline-block; These can be centered using text-align:center, but you'll have to rework the css.

Well, here's one way to do it, you can put a div container around the menu...

#menuContainer{margin: auto;}

<div id='menuContainer' style="width: 980px">

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