【问题标题】:Create a background behind image with full width?在全宽图像后面创建背景?
【发布时间】:2021-05-01 12:42:37
【问题描述】:

我有一个小挑战。我有一个文本宽度固定的 wordpress 主题。我想添加图像,但为每个全宽图像添加背景。这可能吗?

我有制作包装器的想法。将其定位在绝对左侧 0 并使图像居中。

或者有没有办法让某些类忽略规则或者我可以如何例外?

【问题讨论】:

  • 我想我找到了一种方法:.full-width { width: 100vw;位置:相对;左:50%;对:50%;左边距:-50vw;边距右:-50vw; }

标签: html css image append width


【解决方案1】:

我对 WordPress 主题了解不多,但如果是 CSS 就可以了:

body: {
  background-image: url("your url or file path here")
}

【讨论】:

    【解决方案2】:

    试试这个代码可能会解决你的问题

    .yourselecter {
       background-image: url("your image url");
       background-size: 100% 100%;
    }
    

    如果图像是拉伸的,则使用此属性

    .yourselecter {
       background-size: cover;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-19
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      相关资源
      最近更新 更多