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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <!-- this checkbox holds state of whether modal is visible or not -->
<input type="checkbox" id="toggle-modal" checked>

<div class="page-content">
  <h1>Hi, I'm the content behind the modal!</h1>
  <p>You can interact with me after the modal's dismiss animation has finished. Go ahead, try selecting some of this text or clicking the button below to bring the modal back.</p>

  <label for="toggle-modal">Show Modal Again</label>
</div>

<div class="modal">
  <div class="modal-box">
    <h1>Hi, I'm a modal!</h1>
    <p>Notice how I'm preventing you from interacting with the content behind me. Now make me go away!</p>
    <label for="toggle-modal">Dismiss Modal</label>
  </div>
</div>
              
            
!

CSS

              
                *, *::before, *::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

/* center stuff */
body, .modal {
  display: grid;
  align-items: center;
  justify-items: center;
  height: 100%;
}

body {
  margin: 0;
  color: #555;
  background-color: #fff;
  font: 1.25rem/1.5 'Lato', serif;
}

/* hide checkbox, but still expose it to screen readers */
input {
  position: absolute;
  width: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

.page-content {
  max-width: 750px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  margin: 0 0 1rem;
  font-size: 2rem;
}

p {
  margin: 0 0 1.5rem;
}

/* the "dismiss" and "show again" buttons are actually labels that toggle the checkbox */
label {
  display: block;
  padding: 20px;
  color: #fff;
  background-color: #519548;
  text-align: center;
  cursor: pointer;
}

.modal {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: #0009;
}

/* when checkbox is toggled off, dismiss modal */
#toggle-modal:not(:checked) ~ .modal {
  animation: dismiss 1s forwards;
}

@keyframes dismiss {
  to {
    opacity: 0; /* full fade out, but even an invisible element blocks stuff behind it... */
    visibility: hidden; /* ...which is where visibility comes in, to get the modal out of the way */
  }
}

/* also when checkbox is toggled off, hide dismiss button to prevent rapid clicks */
#toggle-modal:not(:checked) ~ .modal label {
  visibility: hidden;
}

.modal-box {
  max-width: 600px;
  margin: 20px 40px;
  padding: 20px;
  background-color: #fff;
}

/* user smaller font sizes on smaller screens */
@media (max-width: 580px) {
  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console