Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <svg display="none" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="768" height="800" viewBox="0 0 768 800"><defs><g id="icon-close"><path class="path1" d="M31.708 25.708c-0-0-0-0-0-0l-9.708-9.708 9.708-9.708c0-0 0-0 0-0 0.105-0.105 0.18-0.227 0.229-0.357 0.133-0.356 0.057-0.771-0.229-1.057l-4.586-4.586c-0.286-0.286-0.702-0.361-1.057-0.229-0.13 0.048-0.252 0.124-0.357 0.228 0 0-0 0-0 0l-9.708 9.708-9.708-9.708c-0-0-0-0-0-0-0.105-0.104-0.227-0.18-0.357-0.228-0.356-0.133-0.771-0.057-1.057 0.229l-4.586 4.586c-0.286 0.286-0.361 0.702-0.229 1.057 0.049 0.13 0.124 0.252 0.229 0.357 0 0 0 0 0 0l9.708 9.708-9.708 9.708c-0 0-0 0-0 0-0.104 0.105-0.18 0.227-0.229 0.357-0.133 0.355-0.057 0.771 0.229 1.057l4.586 4.586c0.286 0.286 0.702 0.361 1.057 0.229 0.13-0.049 0.252-0.124 0.357-0.229 0-0 0-0 0-0l9.708-9.708 9.708 9.708c0 0 0 0 0 0 0.105 0.105 0.227 0.18 0.357 0.229 0.356 0.133 0.771 0.057 1.057-0.229l4.586-4.586c0.286-0.286 0.362-0.702 0.229-1.057-0.049-0.13-0.124-0.252-0.229-0.357z"></path></g></defs></svg>
  
<div class="demo" aria-hidden="false">
  <h1>jQuery Accessible Modal Popup with ARIA Attributes</h1>
  <button class="modal-show">Show modal</button>
</div>

<div class="modal" aria-hidden="true" role="dialog" aria-labelledby="modalTitle" aria-describedBy="modalDescription">
  <div class="modal-overlay modal-hide" tabindex="-1"></div>
  <div class="modal-container modal-hide">
    <div class="modal-wrapper modal-transition">
      <div id="modalDescription" class="modal-description vh">Beginning of dialog window. It begins with a heading 1 called "This is a modal".</div>
      <div class="modal-header">
        <button class="modal-close modal-hide"><svg class="icon-close icon" viewBox="0 0 32 32"><use xlink:href="#icon-close"></use></svg></button>
        <h2 id="modalTitle" class="modal-heading">This is a modal</h2>
      </div>

      <div class="modal-body">
        <div class="modal-content">
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit eum delectus, libero, accusantium dolores inventore obcaecati placeat cum sapiente vel laboriosam similique totam id ducimus aperiam, ratione fuga blanditiis maiores.</p>
          <form action="#">
            <div>
              <label for="name">Text Input:</label>
              <input type="text" name="name" id="name" placeholder="John Smith" />
            </div>
            <br>
            <fieldset>
              <legend>Radio Button Choice</legend>
              <label for="radio-choice-1">Choice 1</label>
              <input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1" />
              <label for="radio-choice-2">Choice 2</label>
              <input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2" />
            </fieldset>
            <br>
            <div>
              <label for="select-choice">Select Dropdown Choice:</label>
              <select name="select-choice" id="select-choice">
                <option value="Choice 1">Choice 1</option>
                <option value="Choice 2">Choice 2</option>
                <option value="Choice 3">Choice 3</option>
              </select>
            </div>
            <br>
            <div>
              <label for="textarea">Textarea:</label>
              <textarea cols="40" name="textarea" id="textarea"></textarea>
            </div>
            <br>
            <div>
              <label for="checkbox">Checkbox:</label>
              <input type="checkbox" name="checkbox" id="checkbox" />
            </div>
            <br>
            <div>
              <button type="submit" class="modal-hide">Update</button>
            </div>
          </form>  
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /**
 * Demo Styles
 */

html {
  box-sizing: border-box;
}

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

html {
  min-height: 100%;
}

body {
  line-height: 1.5;
}

input,
textarea {
  max-width: 100%;
}

.vh {
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0);
  margin: -1px;
  padding: 0;
  width: 1px;
  height: 1px;
  border: 0;
}

/* Page wrapper */
.demo {
  width: 94%;
  max-width: 640px;
  margin: 64px auto;
  text-align: center;
}

/* Icons */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  fill: currentcolor;
}

/** 
 * Modal 
 * 1. Ensure this sits above everything when visible 
 */

.modal {
  position: fixed;
  z-index: 10000; /* 1 */
  top: 0;
  left: 0;
  visibility: hidden;
  width: 100%;
  height: 100%;
}

.modal.is-visible {
  visibility: visible;
}

/* Prevent scrolling on <html> when `.modal` is visible */
.no-scroll {
  overflow: hidden;
}

/* Modal Overlay & Container */
.modal-overlay,
.modal-container {
  position: fixed;
  z-index: 9000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s ease 0.3s, opacity 0.3s ease;
}

.modal-overlay {
  background: hsla(0, 0%, 0%, 0.5);
}

.modal.is-visible .modal-overlay,
.modal.is-visible .modal-container {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* 1. Allow scrolling on `.modal-container` in case `.modal-wrapper` is taller than the viewport */
.modal.is-visible .modal-container {
  overflow: auto; /* 1 */
  -webkit-overflow-scrolling: touch; /* 1 */
}

/* Modal Wrapper */
.modal-wrapper {
  position: absolute;
  z-index: 10000;
  top: 3em;
  left: 50%;
  width: 100%;
  max-width: 600px;
  margin-left: -50%;
  background-color: #fff;
  box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
}

/* Modal Transition */
.modal-transition {
  transition: visibility 0.3s 0.12s, opacity 0.3s 0.12s, transform 0.3s 0.12s;
  transform: translateY(-10%);
  opacity: 0;
}

.modal.is-visible .modal-transition {
  transform: translateY(0);
  opacity: 1;
}

.modal-header,
.modal-content {
  padding: 1em;
}

/* Modal Header */
.modal-header {
  position: relative;
  background-color: #fff;
  box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.06);
  border-bottom: 1px solid #e8e8e8;
}

/* Modal Heading */
.modal-heading {
  font-size: 1.125em;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Modal Close Button */
.modal-close {
  position: absolute;
  top: 0;
  right: 0;
  padding: 1.125em;
  color: #aaa;
  background: none;
  border: 0;
}

.modal-close:hover {
  color: #777;
}

/* Modal Content */
.modal-content > *:first-child {
  margin-top: 0;
}

.modal-content > *:last-child {
  margin-bottom: 0;
}

@media (min-width: 600px) {
  /* Modal Wrapper */
  .modal-wrapper {
    top: 6em;
    margin-left: -300px;
  }
}
              
            
!

JS

              
                // Cache selectors
var html = $('html'),
    demo = $('.demo'),
		modal = $('.modal'),
    modalShow = $('.modal-show'),
    modalHide = $('.modal-hide'),
    modalWrapper = $('.modal-wrapper');

// Modal Show
modalShow.on('click', function(e) {
  e.preventDefault();
  html.addClass('no-scroll');
  modal.addClass('is-visible');
  demo.attr('aria-hidden', 'true');
  modal.attr({
    'aria-hidden': 'false',
    'open': 'true',
    'tabindex': '0'
  });
});

// Modal Hide
modalHide.on('click', function(e) {
  e.preventDefault();
  html.removeClass('no-scroll');
  modal.removeClass('is-visible');
  demo.attr('aria-hidden', 'false');
  modal.attr('aria-hidden', 'true');
  modal.removeAttr('open tabindex');
});

// Prevent toggle event from bubbling
modalWrapper.on('click', function(e) {
  e.stopPropagation();
});
              
            
!
999px

Console