【问题标题】:Wordpress theme css : impossible to change navigation positionWordpress 主题 css:无法更改导航位置
【发布时间】:2014-12-07 12:13:25
【问题描述】:

我正在使用这个免费主题:http://demo2.woothemes.com/mystile/

我想改变主导航菜单的位置(放在中间)。 (有家、商店的那个……)。

我已经浏览了 style.css 和 layout.css(也尝试过使用 firebug),但我找不到它应该在右侧的位置。我猜这是一个“浮动:”?

我发现改变其位置的唯一方法是将其放在 custom.css 中:

body #navigation {
position:absolute;
top:165px;
left: -50%;
right: 0;
margin: auto auto;
}

但这并不完全居中......

有人可以帮我吗?

【问题讨论】:

  • 不行,导航栏还在右边

标签: css wordpress position themes


【解决方案1】:

这取决于你如何设置整个代码。试试这个,看看它有什么帮助

#navigation {
  width:100%;
  left:50%;
  position:absolute;
  text-align:left;
  margin-left:-601px;

【讨论】:

  • 它让它移动,但我怎样才能把它准确地放在中心?
【解决方案2】:

尝试将此属性添加到以下类:

nav#navigation{
 width: 100%;
}
ul#main-nav{
 position: relative;
 right: 50%;
 transform: translateX(50%);
}

此代码将使该菜单居中。

【讨论】:

  • 我在 style.css 或 layout.css 中找不到任何#main-nav,它在哪里?
  • 没关系。将其复制到 ...mystile/style.css 中。如果它不起作用,您应该将 !important 添加到所有属性:nav#navigation{ width: 100% !important; } ul#main-nav{ position: relative !important; right: 50% !important; transform: translateX(50%) !important; }
  • 刚刚试了下,完全没有居中。它只是在左边和中间之间
【解决方案3】:

尝试在样式表中添加这个 css 属性:

#navigation {
    position: absolute;
    width: 100% !important;
    text-align: center;
}
#navigation ul {
    float: none !important;
    display: inline-block;
}

只需将上述 css 代码复制并粘贴到您的 css 样式表中即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-13
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 2018-05-03
    • 2016-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多