更改背景图像大小,但不更改背景颜色
Changing the background image size, but not the background color
我想要一个具有渐变颜色的背景和一张背景图片。它只是一个透明图标,但我想在不影响实际背景大小的情况下更改图标本身的大小。
感谢您的帮助!!
.bg {
background:url(http://icons.iconarchive.com/icons/graphicloads/100-flat/256/announcement-icon.png) no-repeat, linear-gradient(#1cd0d0 10%, #79dcc5 80%, #3bbdb18c 100%);
background-repeat: no-repeat;
background-position: center;
}
<div class="bg">
hi
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
您的 background:
定义有两个背景设置。您可以将 background-size
附加到第一个定义,但它需要写成 position/scale
:
.bg {
background:
url(http://icons.iconarchive.com/icons/graphicloads/100-flat/256/announcement-icon.png) no-repeat center/30%,
linear-gradient(#1cd0d0 10%, #79dcc5 80%, #3bbdb18c 100%);
background-repeat: no-repeat;
background-position: center;
}
<div class="bg">
hi
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
我想要一个具有渐变颜色的背景和一张背景图片。它只是一个透明图标,但我想在不影响实际背景大小的情况下更改图标本身的大小。
感谢您的帮助!!
.bg {
background:url(http://icons.iconarchive.com/icons/graphicloads/100-flat/256/announcement-icon.png) no-repeat, linear-gradient(#1cd0d0 10%, #79dcc5 80%, #3bbdb18c 100%);
background-repeat: no-repeat;
background-position: center;
}
<div class="bg">
hi
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
您的 background:
定义有两个背景设置。您可以将 background-size
附加到第一个定义,但它需要写成 position/scale
:
.bg {
background:
url(http://icons.iconarchive.com/icons/graphicloads/100-flat/256/announcement-icon.png) no-repeat center/30%,
linear-gradient(#1cd0d0 10%, #79dcc5 80%, #3bbdb18c 100%);
background-repeat: no-repeat;
background-position: center;
}
<div class="bg">
hi
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>