Home >Web Front-end >CSS Tutorial >How to Create Holes in CSS Overlays?
Creating Holes in CSS Overlays
It is possible to create an effect that leaves a hole in an overlay, allowing content beneath to show through.
Using CSS Box Shadow
To achieve this effect, use the CSS box-shadow property with a large spread radius.
box-shadow: 0 0 0 9999px rgba(0, 0, 255, 0.2);
This creates a large, translucent shadow around the element.
Example
In the following example, a "hole" is created in the overlay div with the hole class:
.hole { position: absolute; top: 20px; left: 20px; width: 200px; height: 150px; box-shadow: 0 0 0 9999px rgba(0, 0, 255, 0.2); }
<p>Lorem ipsum dolor sit amet, ocurreret tincidunt philosophia in sea, at pro postea ullamcorper.</p> <p>Has ex idque repudiandae, an mei munere philosophia. Sale molestie id eos, eam ne blandit adipisci.</p> <div class="hole"></div>
The above is the detailed content of How to Create Holes in CSS Overlays?. For more information, please follow other related articles on the PHP Chinese website!