【问题标题】:Change the width of the background image using CSS使用 CSS 更改背景图像的宽度
【发布时间】:2014-05-08 15:13:43
【问题描述】:

我有以下代码:

#main {
  background: url(../../images/achtergrond.png) center top repeat-y;
}

可以改变背景图片的宽度吗?

【问题讨论】:

  • 不在后台,没有。

标签: css background-image background-size


【解决方案1】:

您可以使用background-size 属性来执行此操作...

#main {
    background-size: 20px 50px;
    /* Other properties goes here */
}

第一个参数是 X 轴或水平,另一个是 Y 轴或垂直。

所以如果你想改变width你需要将Y参数设置为你想要的单位,X你可以设置为auto

另外,您使用的是速记属性,我为您提供了具体的属性,以便您可以得到我所做的,您当然可以将background-size 整合到您的速记声明中。

【讨论】:

    猜你喜欢
    • 2018-08-03
    • 1970-01-01
    • 2011-10-31
    • 1970-01-01
    • 1970-01-01
    • 2017-07-13
    • 2014-01-19
    • 1970-01-01
    • 2019-04-22
    相关资源
    最近更新 更多