【问题标题】:Centering title does not work (wordpress theme)居中标题不起作用(wordpress 主题)
【发布时间】:2018-09-17 08:47:00
【问题描述】:

我正在修改一个免费的 Wordpress 主题。我快完成了,但这段代码仍然有一个愚蠢的问题:

<div class="page-header">
   <h1 class="page-title">MyTitle</h1>
</div>

页面标题无法居中的原因有哪些?

我已经尝试了这 2 件事,但没有一个可以:

.page-header {text-align: center}
.page-title {text-align: center}

我正在选择正确的组件,因为 display: none 有效。

【问题讨论】:

    标签: css wordpress title centering


    【解决方案1】:
    h1.page-title {
        width: 100%;
        text-align: center !important;
    }
    

    【讨论】:

    • 非常感谢 Albano,它运行良好……这确实是一个很好的组合。再见,泽维尔
    【解决方案2】:

    感谢您的回答。

    是的,我的 css 正在覆盖现有的 css。例如,“显示:无”有效。

    我试过了:

    .page-header, .page-title {
      margin: 0 auto; 
    }
    

    还有这个:

    .page-header, .page-title {
        width: 100%;
        margin-left: auto; 
        margin-right: auto;
    }
    

    ...没有任何成功。

    使标题移动的唯一编码是:

    .page-title {
        margin-left: **400px**; 
        margin-right: auto;
    }
    

    ...但当然一点也不好看。

    这是否敲响了其他解决方案的钟声?

    【讨论】:

      【解决方案3】:

      试试这个:

      .page-header, .page-title {
          width: 100%;
          margin-left: auto; 
          margin-right: auto;
      }
      

      【讨论】:

        【解决方案4】:
        .page-header, .page-title {
          margin: 0 auto; 
        }
        

        如果可行,试试这个文本对齐

        【讨论】:

          【解决方案5】:

          你写的 css 不错,但我认为你的 css 没有覆盖主题的现有 css。

          请将此css放在:仪表板->外观->自定义->附加CSS

          .page-header {text-align: center !important}

          【讨论】:

            猜你喜欢
            • 2016-01-15
            • 1970-01-01
            • 1970-01-01
            • 2013-09-01
            • 1970-01-01
            • 2019-04-11
            • 2019-05-08
            • 2019-01-18
            • 1970-01-01
            相关资源
            最近更新 更多