<div class="wrapper">
<a class="button" href="#pop">Click!</a>
</div>
<div id="pop" class="overlay">
<div class="modal">
<h2>Hey there!</h2>
<a class="close" href="#">×</a>
<div class="content">
So, here we are:<br/>
I am a pure (S)CSS Modal and work with the <strong>:target</strong> element.<br/><br/>
You can close me by clicking the x in the upper left corner or the button at the bottom.<br/><br/>
See you next time:)<br/><br/>
<a class="button" href="#">Close</a>
</div>
</div>
</div>
@mixin border-radius($radius) {
border-radius: $radius;
border-radius: $radius;
border-radius: $radius;
}
html, body {
height: 100%;
font-smoothing: antialiased;
tap-highlight-color: transparent;
}
body {
margin: 0;
background-color: #FAFAFB;
color: slategrey;
}
a.button {
text: {
decoration: none;
align: center;
shadow: 0 1px 0 #fff;
}
color: steelblue;
font-weight: 500;
padding: 8px 15px 8px 15px;
border: 1px solid rgba(26,53,71,.1);
@include border-radius(4px);
transition: .25s;
background: linear-gradient(white, ghostwhite);
&:hover {
border: 1px solid rgba(26,53,71,.2);
background: white;
}
}
.wrapper {
width: 600px;
height: 100%;
margin: auto;
text-align: center;
display: box;
display: box;
display: flexbox;
display: flex;
display: flex;
align-items: center;
justify-content: center;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity .5s;
visibility: hidden;
opacity: 0;
&:target {
visibility: visible;
opacity: 1;
}
}
.modal {
width: 400px;
position: relative;
margin: auto;
padding: 1.5rem;
background: #fff;
@include border-radius(4px);
transition: .5s;
opacity: 0;
.content {
margin-top: 1rem;
a {
max-width: 60%;
margin: auto;
display: block;
}
}
}
.overlay:target > .modal {
transform: translateY(30%) scale(0.9);
transition-timing-function: cubic-bezier(.8, 0, 0, 1.5);
opacity: 1;
}
h2 {
text-align: center;
margin-top: 2rem;
}
a.close {
position: absolute;
top: 15px;
left: 15px;
width: 22px;
height: 22px;
text: {
decoration: none;
align: center;
}
font-size: 20px;
line-height: 21px;
color: lightslategrey;
background-color: lightgrey;
@include border-radius(50%);
transition: .25s;
&:hover {
background-color: tomato;
color: white;
}
}
View Compiled
This Pen doesn't use any external JavaScript resources.