Pretty Simple Modal Window In Pure CSS

Category: CSS & CSS3 , Modal & Popup | March 6, 2017
Author:jreyes88
Views Total:8,811 views
Official Page:Go to website
Last Update:March 6, 2017
License:MIT

Preview:

Pretty Simple Modal Window In Pure CSS

Description:

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>
  </div>
</div>

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;
}

You Might Be Interested In:


One thought on “Pretty Simple Modal Window In Pure CSS

  1. Seynt Jim

    Hello, is there any way to auto load the modal window on page load instead of clicking a button or a link? Thank you!

    Reply

Leave a Reply