问题描述
所以我有如下的CSS代码:
So I have css code as follows:
.jumbobg {
background: url('http://znc.mane-frame.com/static/silverleaf.png') fixed no-repeat, url('../img/banner-1008444.jpg') no-repeat, grey;
}
我想知道第一张图像(silverleaf.png)-如何使用像素(对于Silverleaf)或auto
为该特定图像设置background-size
?我尝试使用background-size
标记,但是它将调整上面定义的所有背景的大小.
I was wondering, for the first image (silverleaf.png) - how would I set the background-size
for that particular image, using either pixels (for silverleaf) or auto
? I tried with background-size
tag, but it would resize all the backgrounds defined above.
推荐答案
问题是您在background
属性中指定了两个背景(用逗号分隔),因此必须对background-size
做同样的操作它们的不同值,当您在background-size
中仅指定一个值时,该值将同时应用于两个图像:
The thing is that you have specified two backgrounds in background
property (separated with comma), so you have to do the same with background-size
to get their distinct values, when you specify only one value in background-size
it is applied for both images, to be clear:
background-size: 50px 80px;
-这是一个值
background-size: 50px 80px, auto;
-这是两个值
像在background
中一样使用逗号分隔符,因此例如,它应该可以按需工作:
Use comma separator as you did in background
, so for example this should work as you want:
background-size: 50px 80px, auto;
这篇关于如何在CSS中设置背景图片大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!