Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Simple Modal // no frameworks </title>
  <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>

<body>

  <!-- Basic Page Structure -->
  <main>

    <div class="container">
      <h1>My page's not that awesome</h1>
      <h2>I swear I won't use bootstrap </h2>

      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Minus magni eligendi inventore, explicabo pariatur quidem laborum nisi error. Iusto hic perspiciatis explicabo praesentium dignissimos sunt unde aliquid laudantium placeat porro.Corporis
        dolor dolorem autem ad deserunt, eum ducimus perferendis corrupti tenetur. Ex necessitatibus placeat nisi illum officia suscipit, aspernatur iste veritatis. Suscipit, deserunt quae in animi rerum eum rem reiciendis.</p>
      <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Minus vero saepe voluptate fugit dignissimos libero sint sequi nisi ipsam iusto, sunt alias sed eius voluptatibus sapiente maiores. Fuga, maxime beatae? </p>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Harum fugiat quis sapiente repellat ad fuga! Quam debitis rem porro fugiat explicabo quo in architecto, esse repellendus, odio dolores, fuga cumque! Veritatis, unde itaque, magni quidem explicabo,
        voluptates at aliquid earum rerum dolor deserunt repellendus velit nesciunt eveniet sed inventore laudantium illum necessitatibus deleniti tempora tenetur. Veritatis, illum! Fugiat, aperiam porro. Qui dolorem veritatis, iure consequatur nulla
        adipisci placeat quibusdam cum odit veniam tempore doloremque, nesciunt molestiae culpa ratione! Debitis quo nobis quam exercitationem ea iste sapiente neque temporibus, repudiandae necessitatibus!</p>

      <h3>I've read all of this, please now take me to the modal</h3>

      <button id="modal-button">Open the modal</button>
    </div>
    <!-- modal start-->
    <div id="overlay" class="overlay-background">
      <div id="modal" class="modal-element">
        <h1>this is a modal</h1>
        <h2>it's very cool</h2>
        <p>and I can add any kind of content in here, heck, even cat pictures</p>
        <img src="https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80" class="responsive" alt="">
        <div id="close-modal" class="close-button" onclick="closeModal();">X</div>
      </div>
    </div>
  </main>

</body>

</html>
              
            
!

CSS

              
                body {
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
}

.container {
    padding: 30px;
}

.overlay-background {
    position: fixed;
    width: 100%;
    top: 0;
    height: 100%;
    background: rgba(0, 0, 0, .8);
}

.hide {
    display: none;
}

.modal-element {
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    position: relative;
    background: white;
    padding: 30px;
    margin: 30px;
}

.responsive {
    max-width: 100%;
    max-height: 350px;
    height: auto;
}

.close-button {
    position: absolute;
    right: -15px;
    top: -15px;
    width: 35px;
    height: 35px;
    background: white;
    box-shadow: -3px 3px 3px rgba(0, 0, 0, .2);
    border-radius: 50%;
    line-height: 35px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
}
              
            
!

JS

              
                 // get the modal element
 overlay = document.getElementById('overlay');
 // add a display none on page load
 overlay.classList.add('hide');


 // get the button elements
 openButton = document.querySelector('#modal-button');
 closeButton = document.querySelector('#close-modal');
 // now get the button to show the modal

 openButton.addEventListener("click", function() {
     overlay.classList.remove('hide');
 })

 closeModal = function() {
     overlay.classList.add('hide');
 }


              
            
!
999px

Console