这样的事情可能吗?
.background { background-size: 50% cover; }
更新:
希望您现在能更好地理解它。
即使一部分消失,图像也应保持成比例。
.background { background-size: 50% cover; }
.background {
border: 5px solid black;
width: 100%;
min-height: 400px;
background-image: url('http://placehold.it/350x150');
background-repeat: no-repeat;
background-position: top right;
background-size: 50% 100%;
}
.text {
padding: 10px;
width: 48%;
}
.center {
display: block;
text-align: center;
}
干杯
不,你不能,
这里是正规的语法的background-size
财产,
= [
|
auto
]{1,2}
|cover
|contain
这意味着无论何时您都cover
无法拥有length-percentage
(这些代表|
OR)
相反,您可以使用background-size: 50% 100%
或background-size: auto 100%
更新根据您更新的问题,您可以使用所需的功能flexbox
div {
display: flex
}
div div:last-of-type {
background: url("http://lorempixel.com/400/200/") no-repeat center / cover;
}
div div {
flex: 1
}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex
ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim
qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.