【问题标题】:How to center the navigation menu on my Wordpress site如何在我的 Wordpress 网站上居中导航菜单
【发布时间】:2018-02-08 15:59:39
【问题描述】:

我正在尝试使用 CSS 使我的 Wordpress 网站上的菜单居中:

http://thewholesomebakery.co.uk/

我知道我必须删除float:left;但随后解决方案似乎从theme 到theme 不等。

谁能帮我解决这个问题?

【问题讨论】:

标签: html css wordpress menu wordpress-theming


【解决方案1】:

使用这个 css:

.site-bar .nav { 
    width: 100%;
    float: none; 
    text-align: center; 
}

.navigation > li { 
    float: none;
    display: inline-block;
}

【讨论】:

    【解决方案2】:

    将你的 css 更改为:

    .site-bar .nav {
        float: left;
        width: 100%;
        padding-top: 3px;
        text-align: center;
    }
    
    .nav ul {
        margin: 0;
        padding: 0;
        list-style: none;
        display: inline-block;
    }
    

    这应该使顶部导航居中!

    【讨论】:

      【解决方案3】:

      您可以删除浮动并添加margin: auto;。 w3c 关于centering things 的页面绝对是任何网络开发人员必读的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-06-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多