I want to design a pop-up that features a container with a black background and some opacity, where the content of the popup is placed inside.
Here's what I have in mind:
<button (click)="showPopup = !showPopup">Open popup</button>
<div class="overlay-bg" (click)="showPopup = !showPopup" [ngClass]="showPopup ? 'is-active' : ''">
<div class="content">Some content</div>
</div>
The CSS code for this setup is as follows:
.overlay {
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
display: grid;
position: fixed;
pointer-events: none;
opacity: 0;
&.is-active {
opacity: 1;
pointer-events: all;
}
.content {
width: 400px;
height: 400px;
place-self: center;
background: red;
}
}
Essentially, the pop-up remains hidden when not active, but clicking the button triggers the display of the overlay and its content. However, I face an issue where clicking on the content also closes the pop-up, which I wish to avoid as the content should be interactive. How can I prevent the pop-up from closing when interacting with the content div?