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

              
                <section>
    <div id="popup">
        <div id="popup__close-btn">&times;</div>
        <h1>Lorem ipsum dolor sit amet</h1>
    </div>
    <article>
        <h1>Lorem ipsum</h1>
        <p>Nullam lorem ante, gravida id tempor id, ultricies egestas velit. Vestibulum nec pellentesque justo. Praesent ante nisi, suscipit eu tellus eget, vestibulum venenatis quam. Aliquam magna sem, facilisis eget dui id, fringilla congue lacus. Maecenas finibus neque ut metus lobortis, non tristique nunc scelerisque.</p>

    </article>
</section>
              
            
!

CSS

              
                section {
    position: relative;
    z-index: 0;
    width: 100vw;
    min-height: 100vh;
    padding: 32px;
}
article {
    width: 650px;
    margin: 0 auto;
    background: #f5f5f5;
}

#popup {
    display: none;
    position: fixed;
    z-index: 1;
    top: -50%;
    left: -50%;
    bottom: -50%;
    right: -50%;
    margin: auto;
    width: 300px;
    height: 300px;
    background-color: #ffffff;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.5);
}

#popup.show {
    display: block;
}

              
            
!

JS

              
                // Popup modal with Vanilla JS

// define popup element...
var popupModal = document.getElementById("popup");
// ... and popup close button inside popupModal
var popupModalCloseBtn = popupModal.querySelector("#popup__close-btn");

// executing openModal() function when DOM is loaded
document.addEventListener("mouseleave", (event) => {
    if (
        event.clientY <= 0 ||
        event.clientX <= 0 ||
        event.clientX >= window.innerWidth ||
        event.clientY >= window.innerHeight
    ) {
        openModal();
    }
});

// Define openModal function
function openModal() {
    // if popupModal exists ...
    if (popupModal) {
        // ... get a session storage cookie and define visibility ...
        let sessionModalCookie = sessionStorage.getItem("modal_closed");
        if (sessionModalCookie) {
            popupModal.classList.remove("show");
            popupModal.remove();
        } else {
            popupModal.classList.add("show");
        }
        if (popupModal) {
            //  ... and add a click event listener for close it
            document.addEventListener("click", function (e) {
                if (e.target == popupModalCloseBtn) {
                    popupModal.classList.remove("show");
                    popupModal.remove();
                    sessionStorage.setItem("modal_closed", "true");
                }
            });
        }
    }
}

              
            
!
999px

Console