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

              
                <div style="background-color: #55FF55; width: 75%; position: relative" id="main"><div class='modal' id='mainModal'><div class='modalBody'>Modal Content</div></div><div style="width: 25%; height: 150px; border: 1px solid black; position: relative; background-color: #EE5555; color: #E6E6E6"><div class='modal' id='topModal'><div class='modalBody'>Modal Content</div></div>Some Text</div>
<div style="width: 25%; height: 150px; border: 1px solid black; position: relative; background-color: #5555EE; color: #E6E6E6"><div class='modal' id='bottomModal'><div class='modalBody'>Modal Content</div></div>Some Text</div>
<button id="topBtn" style="width: 100px; height: 25px;">click top</button>
  <button id="bottomBtn" style="width: 100px; height: 25px;">click bottom</button><button id="mainBtn" style="width: 100px; height: 25px;">click main</button></div>
              
            
!

CSS

              
                .modal {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modalBody {
  background-color: #FEFEFE;
  color: #000000;
  width: 80%;
  height: 40%;
  margin: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border: 3px solid black;
}
              
            
!

JS

              
                // When the user clicks the button, open the modal 
document.getElementById("topBtn").onclick = function() {
    document.getElementById('topModal').style.display = "block";
}

document.getElementById("bottomBtn").onclick = function() {
    document.getElementById('bottomModal').style.display = "block";
}

document.getElementById("mainBtn").onclick = function() {
    document.getElementById('mainModal').style.display = "block";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if ((event.target !== document.getElementById("topBtn")) && (event.target !== document.getElementById("bottomBtn")) && (event.target !== document.getElementById("mainBtn"))) {
        document.getElementById('topModal').style.display = "none";
        document.getElementById('bottomModal').style.display = "none";
        document.getElementById('mainModal').style.display = "none";
    }
}
              
            
!
999px

Console