【问题标题】:WordPress Header background image not responsive and centerWordPress 标题背景图像无响应且居中
【发布时间】:2018-01-22 07:05:10
【问题描述】:

我正在为我的网站使用这个Wordpress Theme,我尝试设置中心或全角图像标题,但它不起作用。图片总是留下,我想知道如何正确地做到这一点,(主题没有提供标题来添加图片选项)

这是我的 CSS

#header .header__top.bg-cat-1 {
  background: url("http://localhost/pro/wp-content/uploads/2018/01/HD.png");
  background-repeat:no-repeat;
  align-content:center;
}

【问题讨论】:

    标签: css background-position


    【解决方案1】:

    试试下面的css:

    background-position: center;
    

    如果你想让背景适合当前部分,试试这个:

    background-size: cover !important;
    

    如果有内联样式,但你找不到它们在哪里,你可以使用 !important 就像你在前面的代码中看到的那样。

    我希望这会有所帮助。

    【讨论】:

    • 先生,感谢您的解决方案
    【解决方案2】:

    尝试使用background-position: center center

    background-position CSS 属性设置每个定义的背景图像的初始位置,相对于background-origin 定义的背景位置层。

    background-position 的默认值为0% 0% 这就是为什么它默认从左上角开始。

    #header .header__top.bg-cat-1 {
      background-image: url("http://localhost/pro/wp-content/uploads/2018/01/HD.png");
      background-repeat: no-repeat;
      background-position: center center;
      background-size: cover;
    }
    

    参考链接:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 1970-01-01
      相关资源
      最近更新 更多