CSS实现底部弧度效果--卡片样式

7,816 阅读1分钟

效果图展示

效果图

代码部分

代码说明、注解

使用了 CSS 的一些属性:

:after 伪类

position 定位

border-radius 圆角边框

linear-gradient 背景颜色渐变

display: flex; flex 布局

box-shadow 盒子阴影

html 代码

<div class="card-wrap">
  <div class="card-box">
    <div class="card-info">content</div>
  </div>
</div>

css 代码

.card-wrap {
  width: 100%;
  height: 188px;
  position: relative;
  z-index: -1;
  overflow: hidden;
}

.card-wrap:after {
  width: 140%;
  height: 168px;
  position: absolute;
  left: -20%;
  top: 0;
  z-index: -1;
  content: '';
  border-radius: 0 0 50% 50%;
  background: linear-gradient(144deg, #3c9cef 0%, #5f6bfd 100%);
}

.card-box {
  position: absolute;
  bottom: 10px;
  width: 100%;

  .card-info {
    margin: auto;
    width: 92%;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    box-shadow: 0 4px 8px 0 rgba(190, 195, 199, 0.5);
    border-radius: 8px;
  }
}