Centering my navigation menu links

杀马特。学长 韩版系。学妹 提交于 2019-11-28 11:52:34

问题


I just can't seem to figure this out. I've tried text-align: center; , display: inline-block and more but I just cant figure out how to center my navigation within the #menu-bottom-nav.

CSS

#menu-bottom-nav { width: 600px; height: 70px; margin: 0px auto;}
#menu-bottom-nav li { list-style-type: none; float: left; margin-right: 20px;}

Any help is appreciated.


回答1:


Try this out:

<!DOCTYPE>

<html>
<head>
    <title>Test</title>

    <style type="text/css">
        #menu-bottom-nav {
            margin: 0;
            padding: 0;
            width: 600px;
            text-align: center;
            border: 1px solid #000;
        }

        #menu-bottom-nav li {
            list-style-type: none;
            margin-right: 20px;
            border: 1px solid #ff0000;
            display: inline-block;
            *display: inline;
            zoom: 1;
        }
    </style>
</head>
<body>
    <ul id="menu-bottom-nav">
        <li>Test</li>
        <li>Test2</li>
        <li>Test3</li>
    </ul>
</body>
</html>


来源:https://stackoverflow.com/questions/10938176/centering-my-navigation-menu-links

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