Pretty Simple Modal Window In Pure CSS

Author: jreyes88
Views Total: 9,158 views
Official Page: Go to website
Last Update: March 6, 2017
License: MIT


Pretty Simple Modal Window In Pure CSS


A dead simple CSS library which lets you create modal windows using pure CSS/CSS3. Powered by :target and :before pseudo classes. Animated with CSS3 transitions and transforms.

How to use it:

Load the primary CSS file modal.css in your document’s head section.

<link rel="stylesheet" href="css/modal.css">

Create the modal content as this:

<div class="modal" id="demo">
  <div class="modal-container">
    <p>I love cats</p>
    <a href="#modal-close">Close</a>

Create a link to toggle the modal window.

<a href="#demo">demo</a>

That’s it. Override the default CSS styles to your taste.

p { margin-top: 0; }
.modal-container {
  position: fixed;
  background-color: #fff;
  width: 70%;
  max-width: 400px;
  left: 50%;
  padding: 20px;
  border-radius: 5px;
  -webkit-transform: translate(-50%, -200%);
  -ms-transform: translate(-50%, -200%);
  transform: translate(-50%, -200%);
  -webkit-transition: -webkit-transform 200ms ease-out;
  transition: transform 200ms ease-out;

See also  16 Single Element Loading Spinners In Pure CSS - SpinBolt

Leave a Reply

Your email address will not be published. Required fields are marked *