我需要将 2 张图片制作成相同尺寸,所以我不想更改第 1 张图片的大小。
到目前为止我有这个
background-image: url("1.png"), url("2.jpg");
background-position: 3% 10%, 83% 27%;
background-size:[I dont want this to have values basically], 83% 27%;
background-repeat: no-repeat, no-repeat;
position: relative;
我也曾尝试将 bg-size 的第一个值留空,但从未奏效。
提前致谢。
最佳答案
尝试使用:
background-size:auto, 83% 27%;
The auto keyword that scales the background image in the corresponding direction such that its intrinsic proportion is maintained.
If the background-size is auto or auto auto: If the image has both intrinsic dimensions, it is rendered at that size. If it has no intrinsic dimensions and no intrinsic proportion, it is rendered at the size of the background positioning area. If it has no dimensions but has a proportion, it's rendered as if contain had been specified instead. If the image has one intrinsic dimension and a proportion, it's rendered at the size determined by that one dimension and the proportion. If the image has one intrinsic dimension but no proportion, it's rendered using the intrinsic dimension and the corresponding dimension of the background positioning area.
关于css background-image - 不要改变第一张图片的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24820321/