这样的事情可能吗?
.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;
}
<div class='background'>
<div class='text'>
<h1>Lorem ipsum</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
</div>
<div class='center'>
<a href='#'>Lorem ipsum</a>
</div>
</div>
干杯
答案 0 :(得分:4)
不,你 ,
以下是background-size
属性的formal syntax,
<bg-size>
= [<length-percentage>
|auto
]{1,2}
|cover
|contain
这意味着只要您cover
length-percentage
,您就无法|
(background-size: 50% 100%
表示OR)
您可以使用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
}
<div>
<div>
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.
</div>
<div>
</div>
</div>
&#13;
Sub NouveauFournisseur() 'OK
Dim i As Integer, shtF As WorkSheet
Set shtF = ThisWorkbook.Worksheets("Fournisseurs")
creation_fournisseur.Show 'affichage de l'userform
If OK Then
i = 0 'boucle pr trouver la ligne vide où copier les données dans le formulaire
Do
i = i + 1
Loop Until shtF.Cells(i, 1) = "" 'jusqu'à ce qu'une ligne soit vide
shtF.Cells(i, 1) = creation_fournisseur.zt_nom
shtF.Cells(i, 2) = creation_fournisseur.zt_adresse
shtF.Cells(i, 3) = Val(creation_fournisseur.zt_tel)
shtF.Cells(i, 4) = Val(creation_fournisseur.zt_fax)
End If
Unload creation_fournisseur 'fermer l'userform
End Sub
&#13;
答案 1 :(得分:0)
您无法使用background-size: 50% cover
本身,但您可以使背景占据宽度的50%和高度的100%。我相信你正在寻找的是:
.background {
background-size: 50% 100%;
}
我创造了一个演示这个here的小提琴。
希望这有帮助!
答案 2 :(得分:0)
您应该将此用作css背景:
.background {
border: 5px solid black;
width: 100%;
min-height: 400px;
background: url('http://placehold.it/350x150') no-repeat right;
background-size: 50% 100%;
}