2016-04-03 22 views
6

Potrzebuję stworzyć niebiesko/zielony obszar, który pokazano na poniższym obrazku. Ma nachylone boki dochodzące do punktu, który ma niewielką krzywiznę.Nagłówek z zaokrąglonym spiczastym dnem

Jaki jest najlepszy sposób osiągnięcia tego przy użyciu CSS? Muszę obsługiwać IE9 + lub IE10 +, jeśli obsługa IE9 nie jest możliwa.

zacząłem podstawowym demo here - (Nie trzeba zawartości w strefie bluey-zielony)

header with curved pointed bottom

Odpowiedz

4

Oto moja próba tylko CSS:

.header { 
    background: #415d67; 
    height: 150px; 
    position: relative; 
    z-index: 1; 

} 
.header:after { 
    position: absolute; 
    content: ""; 
    background: #415d67; 
    width: 50%; 
    bottom: -20px; 
    right: 0; 
    height: 100%; 
    transform: skewY(-5deg); 
    transform-origin: right; 
    border-bottom-left-radius: 50px; 
    padding-right: 44px; 
    z-index: -1; 
} 
.header:before { 
    position: absolute; 
    content: ""; 
    background: #415d67; 
    width: 50%; 
    bottom: -20px; 
    left: 0; 
    height: 100%; 
    transform: skewY(5deg); 
    transform-origin: left; 
    border-bottom-right-radius: 50px; 
    padding-left: 44px; 
    z-index: -1; 
} 
.content { 
    background: white; 
    padding: 20px; 
    padding-top: 100px; 
} 

JSBIN demo

Można również rozważyć użycie grafiki svg.

+0

Awsome wydaje się dobrze działać. Dziękuję Ci! Jedyne, co robię to to, że używam bootstrap i muszę dodać: 'box-sizing: initial' do klas' .header: after' i '.header: before' jako bootstrap używało' box-sizing: border-box; 'które sprawił, że punkt się zwinął. – ifusion

3

Innym podejściem byłoby użycie inline svg. Poniższy przykład wykorzystuje path element poleceniem krzywej beziera na dolnej krzywej:

#header { 
 
    position: relative; 
 
    padding: 30px; 
 
    text-align: center; 
 
    color: #fff; 
 
} 
 
#header svg { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    width: 100%; 
 
    height: 100%; 
 
    z-index: -1; 
 
}
<div id="header"> 
 
    <svg viewbox="0 0 100 20" preserveAspectRatio="none"> 
 
    <path fill="#415D67" d="M0 0 H100 V10 L52.5 19.5 Q50 20 47.5 19.5 L0 10z" /> 
 
    </svg> 
 
    <p>Some content</p> 
 
</div> 
 
<p>some more content</p>

+1

Ach miło, kolejny dobry sposób :) Dziękuję! – ifusion

1

liniowym gradientem mogą być przydatne również: http://codepen.io/gc-nomade/pen/reYWxd

.header { 
 
    background: linear-gradient(to bottom left, #415D67 50%, transparent 51%) bottom left no-repeat, linear-gradient(to bottom right, #415D67 50%, transparent 51%) bottom right no-repeat, linear-gradient(to left, #415D67, #415D67) top no-repeat; 
 
    background-size: 50.1% 30%, 50.1% 30%, 100% 70%; 
 
    height: 105px; 
 
    padding-bottom: 45px; 
 
    /* other makeup from here */ 
 
    display: flex; 
 
} 
 
h1 { 
 
    margin: auto; 
 
    color: turquoise; 
 
    text-shadow:0 0 white; 
 
} 
 
.content { 
 
    background: white; 
 
    padding: 0.25em 20px 20px; 
 
}
<div class="header"> 
 
    <h1>whatever stands here</h1> 
 
</div> 
 
<div class="content"> 
 
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque quia dicta fuga porro esse enim rem laudantium velit dolore doloremque. Esse, voluptatem, consequatur. Rem error unde esse. Architecto, ad, blanditiis. 
 
</div>