【问题标题】:Background image with :before and :after带有 :before 和 :after 的背景图片
【发布时间】:2015-11-24 13:36:42
【问题描述】:

我在响应式网站上有一行,我希望将附加的图像作为背景图像放在顶部和底部。我知道这可以通过伪元素:before:after 来实现,但我不知道该怎么做。
我有行:

.row {
    background: #444444;
}

那么我如何在之前和之后应用图像? https://www.dropbox.com/s/e9h3w2qqvxqntps/background.svg?dl=0

【问题讨论】:

    标签: css background-image pseudo-element


    【解决方案1】:

    以这种方式使用:before:afterbackground-image -

    .row:before {
    content: url('imageURL');
    }
    .row:after {
    content: url('imageURL');
    }
    

    现在您可以使用position: absolute 定位每个:before:after,然后调整topbottom 属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-30
      • 2020-11-17
      • 2022-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多