Home >Web Front-end >CSS Tutorial >How to Create Holes in CSS Overlays?

How to Create Holes in CSS Overlays?

DDD
DDDOriginal
2024-11-08 04:02:01959browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn