带有弯曲尖底的标头

时间:2016-04-03 23:48:42

标签: html css css3 css-shapes

我需要创建下图所示的蓝/绿区域。它的倾斜角度下降到一个略微弯曲的点。

使用 CSS 实现此目标的最佳方法是什么?如果无法支持IE9,我需要支持IE9 +或IE10 +。

我已经开始了一个基本的demo here - (不要求在蓝绿色区域内的内容)

header with curved pointed bottom

3 个答案:

答案 0 :(得分:4)

这是我对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

您还可以考虑使用svg图形。

答案 1 :(得分:3)

另一种方法是使用inline svg。以下示例对底部曲线使用带有贝塞尔曲线命令的path element

#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>

答案 2 :(得分:1)

linear-gradient can be usefull too : 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>