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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <label for="my-modal"
   class="modal-toggle"
   data-toggle="modal"
   aria-controls="my-modal"
   aria-label="Open modal">
  Open modal
</label>

<input type="checkbox" id="my-modal" value="" class="modal-checkbox" value="my-modal">
<div class="modal" role="dialog" aria-labelledby="my-modal-title" aria-describedby="my-modal-desc">
  <div class="modal-body" tabindex="0">
    <div class="modal-header">
      <label for="my-modal"
         class="modal-close"
         data-toggle="modal"
         aria-controls="my-modal"
         aria-label="Close modal"
              tabindex="0">
        <span class="fa fa-close" aria-hidden="true"></span>
      </label>
      <h2 id="my-modal-title">Modal Title</h2>
    </div>
    <div class="modal-content" id="my-modal-desc">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In in diam enim. Phasellus quis dolor sed turpis dictum gravida. Integer iaculis arcu ac lorem varius malesuada. Morbi vulputate elit magna, ut aliquet massa ultrices id. Aenean eu tempus eros, at eleifend lacus. Maecenas ornare, orci vitae ultrices posuere, elit velit sollicitudin libero, at sagittis metus risus sed felis.</p>
      <p>Aliquam at felis est. In augue justo, cursus ac lobortis a, vestibulum eget nulla. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi tempus tellus non ante vulputate pretium. Praesent congue nibh at nulla sagittis cursus. Aliquam rhoncus sem nibh, at fringilla est pharetra in.</p>
    </div>
    <div class="modal-footer">
      <label for="my-modal"
         class="modal-toggle"
         data-toggle="modal"
         aria-controls="my-modal"
         aria-label="Close modal"
              tabindex="0">
        Close modal
      </label>
    </div>
  </div>
</div>

<div class="note">Please note: I don't believe this is the most ideal method to achieve a modal, since :focus is <a href="https://stackoverflow.com/questions/5978239/anyway-to-have-a-label-respond-to-focus-css">rather complicated</a> when it comes to checkboxes and their labels. Using :target is a far better method.</div>
              
            
!

CSS

              
                [data-toggle="modal"] {
  display: inline-block;
  padding: 8px 20px;
  background: #06c;
  color: #fff;
  border-radius: 2px;
  text-decoration: none;
  cursor: pointer;
}

[data-toggle="modal"]:hover,
[data-toggle="modal"]:focus {
  background: #036;
}

.modal-close {
  position: absolute;
  right: 0;
  top: .65em;
  background: none;
  color: #333;
}

.modal-close:hover,
.modal-close:focus {
  color: #036;
  background: none;
}

.modal-checkbox {
  position: absolute;
  left: -100vw;
}

.modal {
  display: none;
  opacity: 0;
  position: fixed;
  width: 100%;
  height: 100vh;
  transition: opacity 0.3s ease;
}

.modal:before {
  position: fixed;
  display: block;  
  content: "";
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 998;
  background: #000;
  background: rgba(0,0,0,.85);
  cursor: default;
}

.modal-checkbox:checked + .modal {
  display: block;
  opacity: 1;
}

.modal-body {
  position: relative;
  z-index: 999;
  background: #fff;
  width: 400px;
  margin: 0 auto;
  -moz-box-shadow: 3px 0 12px rgba(0,0,0,.25);
    -webkit-box-shadow: 3px 0 12px rgba(0,0,0,.25);
    box-shadow: 3px 0 12px rgba(0,0,0,.25);
}

.modal-header {
  padding: 15px 30px;
  border-bottom: 1px solid #ccc;
  background: #f2f2f2;
}

.modal-header h2 {
  margin: 0;
}

.modal-content {
  padding: 15px 30px;
}

.modal-footer {
  padding: 15px 30px;
  border-top: 1px solid #ccc;
  text-align: right;
  background: #f2f2f2;
}

/*
 Demo purposes only
*/
*,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  padding: 30px;
  color: #333;
}

.note {
  margin-top: 3em;
  padding: 15px;
  font-size: 12px;
  line-height: 1.5em;
  background: #FFFACD;
}
              
            
!

JS

              
                
              
            
!
999px

Console