插入背景图片

时间:2014-10-26 09:48:59

标签: css

请原谅我的简单问题!我对编码很陌生并且有一个简单的问题。我目前正在Adobe Business催化剂中建立一个网站并遇到问题。

我想要做的就是将背景图像插入其中一个模块中。理想情况下,像这个图像一样根据模块的大小调整大小。

以下是代码:

<div class="announcement-details">
  <h1>
    <span style="font-size: 28px; color: rgb(0, 174, 239);">{tag_subject}</span>
    <br>
    <span style="font-size: 14px; line-height: 23px;">
    <br>
    <span style="color: rgb(89, 89, 89);">
      {tag_body}
    </span>
    </span>
    <br>
  </h1> 
</div>

2 个答案:

答案 0 :(得分:0)

span.my-class {
    background: url('/path/to/image') no-repeat 0 0;
}

答案 1 :(得分:0)

要设置背景图像,您可以轻松使用css background 属性插入图像并将某些属性设置为背景图像。

在此示例中,我将css属性 background-size:cover 设置为背景图像,以便根据容器大小调整图像大小。

http://jsfiddle.net/77wc17yo/4/

.parent {
    background:#fefefe;
    padding:120px;
    border:3px solid gold;
    text-align:center;
    position:relative;
    background: url('https://eQ3Q') no-repeat center;
    background-size:cover;
}
相关问题