-1

I am trying to apply dimming to the outside of an element. Unfortunately the clip and mask properties in CSS only work on images or svg paths. Here are two examples of the effect I want. I do not want to use JavaScript, only pure CSS.

Mask for image cropper
Mask for image cropper example

Mask for video trimmer

Mask for video trimmer example

agusterodin
  • 417
  • 1
  • 5
  • 17

1 Answers1

0

Adam Argyle (member of Google DevRel) came up with a solution that worked for me.

Cast a box shadow with an extremely large spread (200vmin for example) from the element that you want to be "see through" and apply the overflow: clip property to the container element.

.see-through-element {
  box-shadow: 0 0 0 100vmin hsl(0 0% 0% / 40%);
}

.container-element {
  overflow: clip;
}

Codepen: https://codepen.io/argyleink/pen/MWpyxKd.

agusterodin
  • 417
  • 1
  • 5
  • 17