Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

html - Is there a better way to create convex / concave borders on an element

I've recreated this

enter image description here

.container {
  display: flex;
  flex-direction: column;
  background: rgb(167, 180, 182);
  width: 202px;
}

.top {
  width: 200px;
  height: 100px;
  background: rgb(167, 180, 182);
  border-radius: 0 0 28px 0;
  position: relative;
  z-index: 10;
  filter: drop-shadow(0px 4px 9px rgba(87, 101, 104, 0.4));
}
.bottom {
  width: 200px;
  height: 100px;
  background: rgb(167, 180, 182);
  position: relative;
}

.rounded-bottom {
  overflow: hidden;
  position: absolute;
  bottom: -30px;
  left: 0;
  width: 30px;
  height: 30px;
}
.rounded-bottom__in {
  width: 60px;
  height: 60px;
  border-radius: 100%;
  box-shadow: 0 0 0 500px rgb(167, 180, 182);
}
<div class="container">
  <div class="top">
    <div class="rounded-bottom">
      <div class="rounded-bottom__in"></div>
    </div>
  </div>
  <div class="bottom"></div>
   </div>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Border radius, radial gradient and a filter can do it:

.box {
  width:200px;
  height:200px;
  background:#9baaad;
  position:relative;
  border-bottom-right-radius:50px; /* convexe part */
  filter:drop-shadow(0px 3px 3px grey); /* shadow */
}
/* concave part */
.box::before{
  content:"";
  position:absolute;
  top:100%;
  right:0;
  left:0;
  height:50px;
  background:
    radial-gradient(farthest-side at bottom right,transparent 98%,#9baaad 100%) 
    0/50px no-repeat;
}
<div class="box">

</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...