2016-07-03 5 views
1

要素をカーブさせてから、background-imageプロパティを追加しようとしています。 私はこの質問 - Is there a way to curve an element?を探していました。唯一の違いは、それが曲線の外側にあることです。です。CSS3の要素をカーブ(外側)する方法

は、ここに例を示します

Example of curved-outside image

これは私がしようとしたものです。この結果でhttp://jsfiddle.net/KcmfC/1148/

問題は、それがあまりにも多くの曲面であるということです。私はこれのための解決策を見つけることができません。これについて

#test { 
 
    background: url('http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg') repeat center center/cover; 
 
    border: 0px solid #000; 
 
    width: 100%; 
 
    min-height: 15em; 
 
    border-radius: 0 0 100% 100%; 
 
}
<div id="test"></div>

答えて

2

私がしたことは、私はwidth 140%延伸し、Iはoverflow: hidden介してエッジを "カット"、ビットトリッキーです。ここに私の完全な例です:

#test { 
 
    position: relative; 
 
    overflow: hidden; 
 
    min-height: 150px; 
 
} 
 
#test:before { 
 
    background: url('http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg') repeat center center/1048px 319px; 
 
    border: 0px solid #000; 
 
    content: ""; 
 
    width: 140%; 
 
     height: 100%; 
 
    border-radius: 0 0 100% 100%; 
 
    position: absolute; 
 
    z-index: -1; 
 
    left: -20%; 
 
    right: -20%; 
 
}
<div id="test"> 
 
    <div> 
 
SOME TEXT SOME TEXT SOME 
 
    </div> 
 
</div>

0

reduice border radius pourentage

body{ 
 
    margin:0 
 
    } 
 

 
#test { 
 
    background: url('http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg') repeat center center/cover; 
 
    border: 0px solid #000; 
 
    width: 100%; 
 
    min-height: 15em; 
 
    border-radius: 0 0 35% 35%; 
 
}
<div id="test"> 
 
</div>

+0

を使用することができます。私が与えたイメージの例のように、私は本当に少しだけ必要です。 –

0

何?

#test { 
 
    background: url('http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg') repeat center center/cover; 
 
    border: 0px solid #000; 
 
    width: 100%; 
 
    min-height: 15em; 
 
    border-radius: 0 0 70% 70%/20%; 
 
}
<div id="test"></div>

+0

私はこのアプローチについては考えていませんでしたが、あなたのソリューションは私の質問に少し問題があります。あなたが端で見ることができるように、それは私が欲しがっているようにはまったく見えません。 –

1

あなたがこれはまだあまりにも多くの半径である擬似要素

div { 
 
    background: gray url(http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg) no-repeat center bottom -25px/cover; 
 
    height: 180px; 
 
    position: relative;  
 
} 
 
div:after { 
 
    content: ''; 
 
    background: gray url(http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg) no-repeat center bottom/cover; 
 
    border-radius: 50%; 
 
    width: 100%; 
 
    height: 50px; 
 
    top: calc(100% - 25px); 
 
    left:0; 
 
    position: absolute; 
 
}
<div></div>

+0

同じ画像を2回ロードするというアイデアは好きではなかったし、コーナーは私がやろうとしていたように見えなかった。 –

+0

@EliyaCohen擬似幅を少し大きくすることで簡単に画像コーナーをカットすることができる。あなたはイメージを2度読み込まないでください、それはキャッシュにあり、再利用されます – LGSon

+0

はい、私はそれを行うことができます知っている、私の答えを見てください。あなたはフィードバックを送ることができますか?私は幸せになるでしょう:) –

関連する問題