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

              
                <main>
    <button type="button" id="open-btn" class="btn">Open Modal</button>

    <dialog id="dialog" class="dialog">
        <h3 class="dialog__title">
            Hellow World
        </h3>
        <p class="dialog__txt">
            Nam condimentum quam varius convallis iaculis. Nulla facilisi. Maecenas pretium erat commodo, rhoncus quam quis, laoreet ante. Nunc egestas sapien et magna malesuada faucibus.
        </p>
        <button type="button" id="close-btn" class="btn btn--close dialog__btn">Close</button>
    </dialog>
    
    <p>
       Check the alternative pen for the <a target="_blank" href="https://codepen.io/IbeVanmeenen/pen/RRpLxb">react demo</a>.
    </p>
</main>

<hr>

<footer>
    <h1>
        &lt;dialog&gt; element
    </h1>
    <p>
        The HTML <strong>&lt;dialog&gt;</strong> element represents a dialog box or other interactive component, such as an inspector or window. <br>
        For more info, go to <a target="_blank" href="https://developer.mozilla.org/en/docs/Web/HTML/Element/dialog">https://developer.mozilla.org/en/docs/Web/HTML/Element/dialog</a>
    </p>
    <p>
        Currently only works in Chrome and Opera: <a target="_blank" href="http://caniuse.com/#feat=dialog">http://caniuse.com/#feat=dialog</a>.
    </p>
    <p>
        Polyfill (by GoogleChrome): <a target="_blank" href="https://github.com/GoogleChrome/dialog-polyfill">https://github.com/GoogleChrome/dialog-polyfill</a>.
    </p>
</footer>
              
            
!

CSS

              
                /* Base */
* {
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
            font-smoothing: antialiased;
}

html, body {
    margin: 0;
    padding: 1em;
    
    font-family: sans-serif;
    font-size: 100%;
    line-height: 1.6;
}

html {
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

hr {
    margin: 3rem 0 2rem;
    border: 0;
    border-top: 1px solid #E0E4E8;
}

h1 {
    margin: 0 0 1rem;
}

a {
    color: #648ebb;
}


/* Button */
.btn {
    margin: 0;
    padding: 1em 2em;
    
    line-height: 1;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: #fff;
    background: #50AAFF;
    border: 0;
    font-weight: bold;
}

.btn--inline {
    display: inline-block;
    margin-right: .5rem;
}

.btn--close {
    background: #ff8282;
}


/* Dialog */
.dialog {
    width: 90vw;
    max-width: 20rem;
    
    padding: 1em;
    
    background: #fff;
    color: #656e77;
    box-shadow: 0 0 5px rgba(101, 110, 119, .2);
    border: 0;
    text-align: center;
}

.dialog[open] {
    animation: .2s linear slidein;
}

.dialog::backdrop {
    background: rgba(224, 228, 232, .9);
    animation: .4s ease fade;
}

.dialog__title {
    color: #50AAFF;
}

.dialog__txt {}

.dialog__btn {
    display: block;
    width: 100%;
    margin-top: 2rem;
}


@keyframes slidein {
    from {
        transform: translate3d(0, 5px, 0);
    }
    to {
        transfrom: translate3d(0, 0, 0);
    }
}

@keyframes fade {
    from {
        opacity: .3;
    }
    to {
        opacity: 1;
    }
}
              
            
!

JS

              
                var openBtn = document.getElementById('open-btn');
var closeBtn = document.getElementById('close-btn');
var dialog = document.getElementById('dialog');

openBtn.addEventListener('click', function() {
    dialog.showModal();
});

closeBtn.addEventListener('click', function() {
    dialog.close();
});
              
            
!
999px

Console