2017-07-31 10 views
0

ここに問題があります。私は私の歪曲されたdivを完璧に持っているが、今は誰もが素晴らしいだろうと助けることができるので、タイリングせずにイメージに収まるようにしたい。斜めに区切られた背景画像

私はこのために行くよ: enter image description here

そして、これまでのところ、私はこれがあります。 enter image description here

HTML

<div class="box"></div> 

CSS

.box { 
position:relative; 
width:100%; 
height:500px; 
background: url(../images/clouds.jpeg); 
background-size:contain; 
padding:10px; 
margin-bottom:100px; 

を}

.box:after { 
position:absolute; 
content:''; 
width:100%; 
height:100%; 
top:0; 
left:0; 
right:0; 
background:inherit; 
background-size:contain; 
transform-origin: top left; 
transform:skewY(10deg); 
z-index: -1; 

}

+0

白い隅を別々に歪ませたdivを重ね合わせて、画像の背景を持つ非熟練のdivに重ねるのはどうですか? –

答えて

2

あなたはIMGは、容器全体を埋めるためにしたい場合はbackground-size: coverを使用して、一つの画像を持っているbackground-repeat: no-repeatを使用する必要があります。そのような

何か作業をする必要があります:

画像が歪んでない
.box { 
    position:relative; 
    width:100%; 
    height:500px; 
    background: url(../images/clouds.jpeg); 
    background-size:cover; 
    background-repeat: no-repeat; 
    padding:10px; 
    margin-bottom:100px; 
} 
0

を...

div{ 
 
display:inline-block; 
 
\t margin:10px; 
 
\t postion:relative; 
 
\t width:100px; 
 
\t height:100px; 
 
\t background:cyan; 
 
} 
 

 
div.covered{ 
 
background: 
 
\t linear-gradient(20deg,white,white,40px,transparent 40px,transparent),cyan; 
 
}
<div> 
 
normal 
 
</div> 
 
<div class="covered"> 
 
covered 
 
</div>

左下の部分は白い色で画像を覆うことによって行うことができます傾いた直線勾配である。

+0

私は、代わりにクリッピングパスを使用して、私が望む結果を得ることができました。次の部分は、コンテナの上に次のイメージを重ねることになります – MBarton

+0

この質問を閉じる..アップルは新しい質問をするに値する答えがあれば受け入れます。あなたは別の要素の上にいくつかの要素を置くことに多くのリソースを得ます。 – amit77309