【问题标题】:HTML CSS - Can you define a class with an image using CSS? [duplicate]HTML CSS - 你能用 CSS 定义一个带有图像的类吗? [复制]
【发布时间】:2021-03-21 15:15:39
【问题描述】:

类似的东西

HTML

<button class="img">This button has an image</button>
<button class="img">This button has the same image</button>

CSS

.img {
        url: '/testimage.png'
}

【问题讨论】:

标签: html css


【解决方案1】:

使用background-image 属性。

.img {
  background-image: url("testimage.png");
}

【讨论】:

    猜你喜欢
    • 2015-01-06
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 2012-08-28
    • 2011-05-30
    • 2012-11-03
    • 2019-12-05
    • 2013-02-03
    相关资源
    最近更新 更多