2017-06-30 103 views
0

如何让边界向内弯曲而不是向外弯曲?边界半径曲线向内?

例如 - 这是向外弯曲:

header { 
 
    position: relative; 
 
    height: 300px; 
 
    background-image: linear-gradient(#ff9d2f, #ff6126); 
 
    border-bottom-left-radius: 50% 20%; 
 
    border-bottom-right-radius: 50% 20%; 
 
} 
 

 
h1 { 
 
    margin: 0; 
 
    padding: 100px 0; 
 
    font: 44px "Arial"; 
 
    text-align: center; 
 
} 
 

 
header h1 { 
 
    color: white; 
 
}
<header> 
 
    <h1>Header Content</h1> 
 
</header> 
 

 
<section> 
 
    <h1>Section Content</h1> 
 
</section>

我想它想的曲线向内,这可能吗?

+0

您可以通过使用'after'或得到'before' – LKG

+0

@LokeshGupta任何例子吗? – laukok

+0

检查我张贴的工作示例作为答案 – LKG

回答

1

像下面的例子

header { 
 
    position: relative; 
 
    height: 300px; 
 
    background-image: linear-gradient(#ff9d2f, #ff6126); 
 
} 
 

 
h1 { 
 
    margin: 0; 
 
    padding: 100px 0; 
 
    font: 44px "Arial"; 
 
    text-align: center; 
 
} 
 

 
header h1 { 
 
    color: white; 
 
} 
 

 
header:after { 
 
    content: ''; 
 
    position: absolute; 
 
    bottom: 0; 
 
    left: 0; 
 
    height: 30%; 
 
    width: 100%; 
 
    background: #fff; 
 
    border-top-left-radius: 50% 20%; 
 
    border-top-right-radius: 50% 20%; 
 
    user-select: none; 
 
}
<header> 
 
    <h1>Header Content</h1> 
 
</header> 
 

 
<section> 
 
    <h1>Section Content</h1> 
 
</section>

+0

感谢您的答案! – laukok

1

可以使用另一个盒子模拟它,如果这是你所需要的。

header { 
 
    position: relative; 
 
    height: 300px; 
 
    background-image: linear-gradient(#ff9d2f, #ff6126); 
 
} 
 

 
header:after { 
 
    content: " "; 
 
    width: 100%; 
 
    height: 100px; 
 
    position: absolute; 
 
    background-color: white; 
 
    bottom: 0; 
 
    border-top-left-radius: 50% 40%; 
 
    border-top-right-radius: 50% 40%; 
 
} 
 

 
h1 { 
 
    margin: 0; 
 
    padding: 100px 0; 
 
    font: 44px "Arial"; 
 
    text-align: center; 
 
} 
 

 
header h1 { 
 
    color: white; 
 
}
<header> 
 
    <h1>Header Content</h1> 
 
</header> 
 

 
<section> 
 
    <h1>Section Content</h1> 
 
</section>

+0

感谢您的回答! – laukok