【问题标题】:Center footer on wordpress themewordpress 主题的中心页脚
【发布时间】:2020-01-10 15:07:03
【问题描述】:

我目前正在创建一个网站并使用非常好的 Reykjavik 主题。首先,我创建了一个儿童主题。现在,我想对子主题进行一些修改。 在此模板中,可以个性化页脚,但不能更改其位置。我提供用页面检查器检查它的位置,但没有找到任何东西......

我提供修改我的 style.css 子主题,将相对位置添加到页脚,但它不会改变任何东西..

您知道如何将页脚文本居中吗?

非常感谢:)

杰瑞

【问题讨论】:

  • 您当前有 span,它是一个内联元素。添加显示:块;和文本对齐:居中;这应该会有所帮助。
  • 感谢您的帮助@GrzegorzT。 !正如你所说,我试图修改 style.css 文件,所以没有 position: relative 但有 display: block;和文本对齐:居中;但它并没有改变任何东西:(
  • 在测试Ⓒ 2019 之前我没有注意到跨度关闭 :) 您需要处理的类是 site-info。在那里,添加一个文本中心,最好显示这个类里面有什么。
  • @GrzegorzT。是的,它是站点信息的一部分 :) 但不是放在 style.css 文件中?
  • @GrzegorzT。 PS:我编辑了我的帖子;是不是因为文字的框架太小了?

标签: html css wordpress wordpress-theming footer


【解决方案1】:

如果您要使块元素居中

这是如果您尝试将 <div><img> 等居中。
W3Schools list of inline and block elements

您可以考虑使用margin: 0 auto;

.centered {
  margin: 0 auto;
  /*margin:0 auto: this gives the element a 0 top and bottom margin, and automatically sets the left and right to the maximum it can be*/
  width:100px;
  /*You need to specify a width for this to work*/
}
<div>
  <p class="centered">
    Hello World
  </p>
</div>

如果您将内联元素居中

对于内联元素,例如&lt;span&gt;&lt;img&gt; 或文本元素
W3Schools list of inline and block elements

为此,您可以使用text-align:center;

.centered {
  text-align: center;
  /*Just tell the text to center itself in the element*/
}
<p class="centered">
  Hello World!
</p>

来源

W3Schools list of inline and block elements
CSS Tricks: Centering in CSS

【讨论】:

  • 谢谢罗南!我尝试添加文本对齐代码但不起作用...是不是因为文本的框架太少了?
【解决方案2】:

我们在 site-info 类中添加边距:auto 然后文本居中。

.site-info { margin: auto }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-27
    • 1970-01-01
    • 2019-03-10
    • 2012-09-12
    • 2021-02-07
    • 2014-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多