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

How to Create Holes in CSS Overlays?

DDD
Release: 2024-11-08 04:02:01
Original
1076 people have browsed it

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);
Copy after login

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);
}
Copy after login
<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>
Copy after login

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 of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template