Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

css - Does the background size apply to both images?

I have a responsive landing page with two background images. I need both images to have a background-size of 40% but I'm not sure if the way I wrote the CSS the background size is only affecting the first image.

This is my CSS:

.section-one {
   background: url(image-here.svg) left bottom no-repeat,
               url(another-image.svg) right bottom no-repeat;
   background-size: 40%;
   padding-bottom: 200px;
}

This is how the screen recording's showing the CSS. If you notice, the 40% is only being applied to the first image: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Why not use the background directive shortcut all the way like this to be sure?

CSS

.section-one {
   background: no-repeat left bottom/40%   url('image-here.svg'),
               no-repeat right bottom/40%  url('another-image.svg');
   padding-bottom: 200px;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...