I came across this:
/*
The main content is inside of our <main> element.
Make it fill the whole window and be scrollable - body should not scroll.
*/
body {
margin: 0;
padding: 0;
overflow: hidden;
}
.content {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
overflow: scroll;
}
/*
Modals should cover the whole screen, but be hidden by default.
When we click a link to #ModalName, #ModalName becomes the :target element and we can use this selector to give it new styles, like display:block;
Notice our "Close" links have an href of "#", which means none of our modals are now the :target. They will now all fall back to the basicl .modal styling.
*/
.modal {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: none;
opacity: 0;
overflow: scroll;
}
.modal:target {
display: block;
z-index: 2;
opacity: 1;
}
.popup:target ~ .content {
overflow: hidden;
}
/* ----------------------------
Styling just for funsies.
You can ignore this.
------------------------------- */
body {
font-family: helvetica, arial, sans-serif;
font-weight: 100;
text-align: center;
color: #FFF;
}
.content {
background-color: #EDEBEE;
}
.modal-exit,
.modal-exit:hover {
position: fixed;
top: 0;
right: 0;
width: 1em;
height: 1em;
z-index: 10;
padding: 0.3em;
font-size: 2em;
line-height: 1em;
text-decoration: none;
color: #FFF;
}
.modal-exit:hover {
background-color: rgba(255,255,255, 0.3);
}
.modal-open,
.modal-open:hover {
display: block;
width: 10em;
margin: 1em auto;
padding: 2em 1em;
border: 1px solid #806973;
background-color: #FFF;
font-size: 2em;
text-align: center;
text-decoration: none;
color: #806973;
box-shadow: 0 0 10px 1px #CCC;
}
.modal-open:hover {
box-shadow: 0 0 10px 1px #999;
}
.modal-title {
font-size: 3em;
font-weight: 100;
}
.modal-description {
padding: 1em;
font-size: 1.2em;
letter-spacing: 0.1em;
color: #EDEBEE;
}
.bg--purple {
background-color: #806973;
}
.bg--blue {
background-color: #696E80;
}
.bg--red {
background-color: #806969;
}
.bg--green {
background-color: #69807D;
}
<section class="modal bg--purple" role="dialog" id="modalA" aria-labelledby="modalA-title" aria-describedby="modalA-description">
<a href="#" class="modal-exit" title="close">×</a>
<h1 id="modalA-title" class="modal-title">Modal A</h1>
<p id="modalA-description" class="modal-description">Lots of fun things in here to see.</p>
</section>
<section class="modal bg--blue" role="dialog" id="modalB" aria-labelledby="modalB-title" aria-describedby="modalB-description">
<a href="#" class="modal-exit" title="close">×</a>
<h1 id="modalB-title" class="modal-title">Modal B</h1>
<p id="modalB-description" class="modal-description">Lots of fun things in here to see.</p>
</section>
<section class="modal bg--red" role="dialog" id="modalC" aria-labelledby="modalC-title" aria-describedby="modalC-description">
<a href="#" class="modal-exit" title="close">×</a>
<h1 id="modalC-title" class="modal-title">Modal C</h1>
<p id="modalC-description" class="modal-description">Lots of fun things in here to see.</p>
</section>
<section class="modal bg--green" role="dialog" id="modalD" aria-labelledby="modalD-title" aria-describedby="modalD-description">
<a href="#" class="modal-exit" title="close">×</a>
<h1 id="modalD-title" class="modal-title">Modal D</h1>
<p id="modalD-description" class="modal-description">Lots of fun things in here to see.</p>
</section>
<section class="modal bg--purple" role="dialog" id="modalE" aria-labelledby="modalE-title" aria-describedby="modalE-description">
<a href="#" class="modal-exit" title="close">×</a>
<h1 id="modalE-title" class="modal-title">Modal E</h1>
<p id="modalE-description" class="modal-description">Lots of fun things in here to see.</p>
</section>
<main class="content">
<a href="#modalA" class="modal-open">
View Modal A
</a>
<a href="#modalB" class="modal-open">
View Modal B
</a>
<a href="#modalC" class="modal-open">
View Modal C
</a>
<a href="#modalD" class="modal-open">
View Modal D
</a>
<a href="#modalE" class="modal-open">
View Modal E
</a>
</main>