To achieve this effect using only CSS, you can create a separate container with the class "popup." Inside this container, add another container for the popup content. Set the background of the parent popup container to rgba(black,0.7);
, and ensure that it has visibility:hidden; opacity:0
initially.
Assign the id="popup"
to the parent container so that it has both an id and a class of "popup."
The element that triggers the popup display should be an anchor tag with href="#popup"
, like this:
<a href="#popup">Info</a>
. Then utilize the
:target
pseudo-class in your CSS code:
.popup{
height: 100vh;
width: 100%;
position: fixed;
top: 0;
left: 0;
background-color: rgba(black, 0.7);
z-index: 100;
opacity: 0;
visibility: hidden;
}
.popup:target {
opacity:1;
visibility: visible
}
To close the popup window, include an "x" button in the upper right corner as an anchor tag with href="#home_page"
. Give the home page section the id="home_page"
, so clicking the button will redirect you to the Home page.