0

I have a transparent radial gradient that I'm using as a mask image in order to "cut a hole with the shape of a half circle" in a div.

I'm using a transparent radial gradient because I want the "hole" to be an actual "hole" (meaning, I want to be able to see the content that is "behind" the div).

Demo:

div {
  width: 200px;
  height: 200px;
  background-color: green;
  border: 2px solid black;
  
  -webkit-mask-image: radial-gradient(
    circle at center top,
    transparent 30px,
    black 31px
  );
}
<div>

</div>

How can I add a border (let's "2px solid black") to the half-circle shape?

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
alexandernst
  • 14,352
  • 22
  • 97
  • 197

1 Answers1

1

add a gradient coloration using the same radial-gradient:

div {
  width: 200px;
  height: 200px;
  background: 
     radial-gradient(
      circle at center top,
      transparent 30px,
      black 30px 32px,
      green 33px
    ) border-box;
  border: 2px solid black;
  
  -webkit-mask-image: radial-gradient(
    circle at center top,
    transparent 30px,
    black 31px
  );
}
<div>

</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415