<h1>Popup Please</h1>
<a href="#popup1" class="btn">Reveal Popup</a>
<div id="popup1" class="popup">
<a href="#" class="close">×</a>
<h2>The Popup Has Arrived</h2>
<p>This popup can be closed by clicking the fancy <b>×</b> in the top right corner or by clicking outside the popup box!</p>
</div>
<a href="#" class="close-popup"></a>
*,
*:before,
*:after {
box-sizing: border-box;
}
html, body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
body {
text-align: center;
background-image: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%);
background-size: cover;
background-repeat: no-repeat;
}
h1,h2,a,p {
font-family: helvetica, sans-serif;
}
h1 {
font-size: 3em;
text-align: center;
color: #00898E;
margin: 0;
padding: 30vh 0 1em;
}
h2 {
text-align: center;
white-space: nowrap;
color: #00898E;
}
a {
text-decoration: none;
color: #fff;
}
p {
text-align: left;
}
.btn {
display: inline-block;
padding: 10px 20px;
border: 2px solid #00898E;
border-radius: 10px;
transition: background .3s;
}
.btn:hover {
background: #00898E;
}
.popup {
position: fixed;
padding: 10px;
max-width: 500px;
border-radius: 10px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: rgba(255,255,255,.9);
visibility: hidden;
opacity: 0;
/* "delay" the visibility transition */
-webkit-transition: opacity .5s, visibility 0s linear .5s;
transition: opacity .5s, visibility 0s linear .5s;
z-index: 1;
}
.popup:target {
visibility: visible;
opacity: 1;
/* cancel visibility transition delay */
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
.popup-close {
position: absolute;
padding: 10px;
max-width: 500px;
border-radius: 10px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: rgba(255,255,255,.9);
}
.popup .close {
position: absolute;
right: 5px;
top: 5px;
padding: 5px;
color: #000;
transition: color .3s;
font-size: 2em;
line-height: .6em;
font-weight: bold;
}
.popup .close:hover {
color: #00E5EE;
}
.close-popup {
background: rgba(0,0,0,.7);
cursor: default;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
visibility: hidden;
/* "delay" the visibility transition */
-webkit-transition: opacity .5s, visibility 0s linear .5s;
transition: opacity .5s, visibility 0s linear .5s;
}
.popup:target + .close-popup{
opacity: 1;
visibility: visible;
/* cancel visibility transition delay */
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
// ¯\_(ツ)_/¯
/*
My own version of https://codepen.io/imprakash/pen/GgNMXO
*/
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.