Cut off rounded rects with clip-path while maintaining border-radius and box-shadow

Viewed 21

I have a scrollable list of divs that each have a border-radius and box-shadow. To allow an element below the list to remain visible, the list is cut off using clip-shape. I would like to keep both the shadow and border radius of the clipped rectangles. I have found several working examples for either the shadow or the radius, but I can't find anything that can do both at the same time.

#main {
  background-color: lightblue;
  position: relative;
  height: 100vh;
  width: 100vw;
  overflow-y: hidden;
}

body {
  margin: 0;
}

#overlay {
  width: 100vw;
  height: 95vh;
  overflow-y: scroll;
  position: absolute;
  clip-path: inset(5vh 0px 0px);
  padding-top: 5vh;
}

#overlay::-webkit-scrollbar {
  display: none;
}

.overlay-card {
  margin: 10px 10px 30px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  height: 500px;
  padding: 30px;
}
<div id="main">
  <center>root/header</center>
  <div id="overlay">
    <div class="overlay-card">overlay content</div>
    <div class="overlay-card">overlay content</div>
  </div>
</div>

demonstration screenshots of current and desired appearance

Is the effect above possible? Am I approaching this problem correctly?

0 Answers
Related