css - 如何使用 style.css 在 Wordpress 中将菜单居中

标签 css wordpress

我在style.css中有这段代码

ul#secondary-menu {
    padding-left: 18px;
    width:960px;
}

如何将其对齐以在页面中居中?

我正在谈论的页面位于: http://unacunatura.highacid.com/

最佳答案

在 CSS 中将其添加到您的 id 中

    ul#secondary-menu { 
    padding-left: 18px; 
    margin: auto;
    width: 300px;
   }

当然,宽度将定义菜单的宽度,但边距自动会将其与父菜单居中对齐。

鉴于它是一个子菜单,您不需要将其宽度设置为 960px,只需将宽度设置为内容的宽度即可。

编号:http://www.w3schools.com/css/css_margin.asp

关于css - 如何使用 style.css 在 Wordpress 中将菜单居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23316446/

相关文章:

php - 限制 woocommerce 购物篮大小

jQuery mouseenter 效果不工作

wordpress - WooCommerce:向购物车中的每个项目添加输入字段

php - fatal error : Call to a member function get_results() on a non-object (jQuery From Plugin & WordPress)

wordpress - Wordpress 中的登录用户列表?

php - 我需要在 woocommerce 中添加自定义查询并添加到购物车按钮动态代码吗?

html - 如何使 md-hint 居中对齐(material2)

html - CSS 按钮值样式

html - div 垂直 float

javascript - React Native 边框半径制作轮廓