Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create css concave/convex shapes

I want to create two divs with the background white shape depicted below. As you can see it's basically a rectangle and a ellipse-shape being cut out. It should be able to produce a box-shadow.

Is there a way to achieve this with css only?

Concave shapes

like image 450
Han Che Avatar asked Jun 20 '16 11:06

Han Che


1 Answers

I have used 2 div's with box-shadow i have added border for understanding

body {
  background:url(https://placeimg.com/640/480/any);
}

.out {
  width: 455px;
  height: 275px;
  border: 1px solid red;
  position: relative;
  overflow: hidden;
  margin: 20px;
}

.in {
  width: 550px;
  height: 550px;
  border: 1px solid green;
  position: absolute;
  left: 200px;
  border-radius: 50%;
  box-shadow: 0 0 0 500px white; /* this is the white background */
}

.bottom .in {
  bottom: 0;
  left: 200px;
}
<div class="out">
  <div class="in">

  </div>
</div>

<div class="out bottom">
  <div class="in">

  </div>
</div>
like image 146
Vitorino fernandes Avatar answered Nov 09 '22 20:11

Vitorino fernandes