奇葩的优惠券样式


类似上面这样的优惠券图片怎么用css实现啊?
两边有圆角凹陷,还有白色边框,背景色还是带透明度的。。。

实现了一下效果都不行,有更好的解决方案吗?

阅读 3.9k
4 个回答
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Home</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" href="styles.css" />
    <script type="module" src="script.js"></script>
  </head>
  <body>
    <div class="card_wrapper">
      <div class="card"></div>
    </div>
  </body>
</html>
* {
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.card_wrapper {
  width: 300px;
  height: 140px;
  overflow: hidden;
}

.card {
  width: 300px;
  height: 140px;
  border: 1px solid orange;
  border-radius: 20px;
  position: relative;
  box-sizing: border-box;
}

.card::before,
.card::after {
  content: '';
  position: absolute;
  top: 50%;
  background-color: #fff;
  transform: translateY(-50%);
  border: 1px solid orange;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.card::before {
  left: -20px;
}

.card::after {
  right: -20px;
}

效果:
image.png

在线链接

推荐问题
宣传栏