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

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

              
                <div class="md-modal" id="modal">
  <div class="md-inner">
    <div class="md-header">
      <h3>Important!</h3>
    </div>
    <div class="md-content">
      <div>
        <p>Tofu lomo synth succulents venmo tacos gentrify. Shoreditch palo santo narwhal helvetica man braid tofu, umami sriracha bicycle rights intelligentsia portland banh mi. Crucifix echo park lo-fi gluten-free unicorn cronut austin bitters, try-hard
          retro asymmetrical. Church-key tote bag messenger bag pickled affogato cardigan cronut. Vaporware distillery keytar gastropub prism vinyl hammock knausgaard af brunch. Readymade prism craft beer ennui, flannel neutra photo booth gluten-free
          food truck art party chicharrones plaid. Cliche taxidermy waistcoat iceland intelligentsia master cleanse hexagon la croix semiotics tote bag XOXO vaporware tousled. Viral small batch fingerstache green juice man braid, austin letterpress offal
          bicycle rights slow-carb dreamcatcher asymmetrical authentic PBR&B lomo. Locavore hexagon roof party whatever. Cronut live-edge twee swag, messenger bag cliche lumbersexual try-hard banjo street art. Cred kale chips photo booth dreamcatcher
          biodiesel pinterest.</p>
        <p>Ramps intelligentsia next level post-ironic yr. Vegan crucifix narwhal, craft beer tofu post-ironic +1 hoodie offal put a bird on it green juice mixtape adaptogen direct trade glossier. Fixie master cleanse bushwick affogato everyday carry pug
          next level pickled cold-pressed la croix umami live-edge vinyl roof party hoodie. Williamsburg tattooed chartreuse locavore pok pok hexagon 3 wolf moon cray hoodie ramps kitsch. Mlkshk bitters cold-pressed, ennui crucifix single-origin coffee
          health goth echo park pug. Meditation kinfolk farm-to-table banjo. Gentrify pitchfork helvetica XOXO meditation pour-over selfies copper mug godard taxidermy banjo snackwave ugh hell of jean shorts. Gochujang hexagon hoodie man braid banjo palo
          santo, lomo master cleanse knausgaard jianbing normcore tumeric. Ramps kitsch paleo, blue bottle vexillologist lo-fi DIY shoreditch craft beer raclette copper mug 8-bit brunch pickled prism. Pug single-origin coffee echo park, drinking vinegar
          farm-to-table intelligentsia whatever +1 YOLO bespoke.</p>
      </div>
    </div>
    <div class="md-footer">
      <button class="md-close">Got it!</button>
    </div>
  </div>
</div>
<div class="container">
  <button data-modal="modal">Open modal</button>
  <p><em>no</em> scroll</p>
  <p><em>no</em> scroll</p>
  <p><em>no</em> scroll</p>
  <button data-modal="modal">Open modal</button>
  <p><em>no</em> scroll</p>
  <p><em>no</em> scroll</p>
  <p><em>no</em> scroll</p>
  <button data-modal="modal">Open modal</button>
  <p><em>no</em> scroll</p>
  <p><em>no</em> scroll</p>
  <p><em>no</em> scroll</p>
  <button data-modal="modal">Open modal</button>
</div>
<!-- /container -->
<div class="md-overlay"></div>
<!-- the overlay element -->
              
            
!

CSS

              
                *, *:after, *:before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

body, html {
    font-size: 100%;
    padding: 0;
    margin: 0;
}

/* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
.clearfix:before, .clearfix:after {
    content: " ";
    display: table;
}

.clearfix:after {
    clear: both;
}

body {
    font-family: 'Lato', Calibri, Arial, sans-serif;
    color: #fff;
    background: #e74c3c;
}

a {
    color: #ffffff;
    &:hover, &:active {
        text-decoration: none;
    }
}

button {
    border: none;
    padding: 0.6em 1.2em;
    background: #c0392b;
    color: #fff;
    font-family: 'Lato', Calibri, Arial, sans-serif;
    font-size: 1em;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-block;
    margin: 3px 2px;
    border-radius: 2px;
    &:hover {
        background: #A5281B;
    }
}

@media screen and (max-width: 46.0625em) {
    .container {
        width: 100%;
        min-width: auto;
        min-height: auto;
        padding: 1em;
    }
}

.container {
    background: #e74c3c;
    min-height: 100%;
    text-align: center;
    padding: 20px 0;
    p {
        margin: 1vw;
        text-align: center;
        font-size: 10vw;
    }
    p:nth-child(4n) {
        color: rgba(255, 255, 255, 1);
    }
    p:nth-child(4n+1) {
        color: rgba(255, 255, 255, 0.2);
    }
    p:nth-child(4n+2) {
        color: rgba(255, 255, 255, 0.4);
    }
    p:nth-child(4n+3) {
        color: rgba(255, 255, 255, 0.6);
    }
    p:nth-child(4n+4) {
        color: rgba(255, 255, 255, 0.8);
    }
    em {
        display: none;
    }
}

.no-scroll {
    &, & body {
        overflow: hidden;
    }
    em {
        display: inline;
    }
}

.md-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 80%;
    max-width: 800px;
    min-width: 320px;
    height: 50vh;
    max-height: 400px;
    min-height: 200px;
    z-index: 2000;
    visibility: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateX(-50%) translateY(-50%);
    -moz-transform: translateX(-50%) translateY(-50%);
    -ms-transform: translateX(-50%) translateY(-50%);
    transform: translateX(-50%) translateY(-50%);
    background: #e74c3c;
    border-radius: 3px;
    .md-header {
        h3 {
            margin: 0;
            padding: 0.4em;
            text-align: center;
            font-size: 2.4em;
            font-weight: 300;
            opacity: 0.8;
            background: rgba(0, 0, 0, 0.1);
            border-radius: 3px 3px 0 0;
        }
    }
    .md-footer {
        position: absolute;
        height: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        color: #fff;
        text-align: center;
    }
}

.md-show {
    visibility: visible;
}

.md-overlay {
    position: fixed;
    width: 100%;
    height: 100%;
    visibility: hidden;
    top: 0;
    left: 0;
    z-index: 1000;
    opacity: 0;
    background: rgba(143, 27, 15, 0.8);
    -webkit-transition: opacity 0.3s;
    -moz-transition: opacity 0.3s;
    transition: opacity 0.3s;
}

.md-show ~ .md-overlay {
    opacity: 1;
    visibility: visible;
}

.md-content {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 80px;
    color: #fff;
    overflow-y: auto;
    overflow-x: none;
    -webkit-overflow-scrolling: touch;
    > div {
        padding: 15px 40px 30px;
        margin: 0;
        font-weight: 300;
        font-size: 1.15em;
        p {
            margin: 0;
            padding: 10px 0;
        }
        ul {
            margin: 0;
            padding: 0 0 30px 20px;
            li {
                padding: 5px 0;
            }
        }
    }
}

.md-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-transform: scale(0.7);
    -moz-transform: scale(0.7);
    -ms-transform: scale(0.7);
    transform: scale(0.7);
    opacity: 0;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    transition: all 0.3s;
}

.md-show .md-inner {
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    -ms-transform: scale(1);
    transform: scale(1);
    opacity: 1;
}
              
            
!

JS

              
                var disableBodyScroll = (function () {

    /**
     * Private variables
     */
    var _selector = false,
        _element = false,
        _clientY;

    /**
     * Polyfills for Element.matches and Element.closest
     */
    if (!Element.prototype.matches)
        Element.prototype.matches = Element.prototype.msMatchesSelector ||
        Element.prototype.webkitMatchesSelector;

    if (!Element.prototype.closest)
        Element.prototype.closest = function (s) {
            var ancestor = this;
            if (!document.documentElement.contains(el)) return null;
            do {
                if (ancestor.matches(s)) return ancestor;
                ancestor = ancestor.parentElement;
            } while (ancestor !== null);
            return el;
        };

    /**
     * Prevent default unless within _selector
     * 
     * @param  event object event
     * @return void
     */
    var preventBodyScroll = function (event) {
        if (false === _element || !event.target.closest(_selector)) {
            event.preventDefault();
        }
    };

    /**
     * Cache the clientY co-ordinates for
     * comparison
     * 
     * @param  event object event
     * @return void
     */
    var captureClientY = function (event) {
        // only respond to a single touch
        if (event.targetTouches.length === 1) { 
            _clientY = event.targetTouches[0].clientY;
        }
    };

    /**
     * Detect whether the element is at the top
     * or the bottom of their scroll and prevent
     * the user from scrolling beyond
     * 
     * @param  event object event
     * @return void
     */
    var preventOverscroll = function (event) {
        // only respond to a single touch
	    if (event.targetTouches.length !== 1) {
	    	return;
	    }

	    var clientY = event.targetTouches[0].clientY - _clientY;

	    // The element at the top of its scroll,
	    // and the user scrolls down
	    if (_element.scrollTop === 0 && clientY > 0) {
	        event.preventDefault();
	    }

	    // The element at the bottom of its scroll,
	    // and the user scrolls up
		// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
		if ((_element.scrollHeight - _element.scrollTop <= _element.clientHeight) && clientY < 0) {
	        event.preventDefault();
	    }

    };

    /**
     * Disable body scroll. Scrolling with the selector is
     * allowed if a selector is porvided.
     * 
     * @param  boolean allow
     * @param  string selector Selector to element to change scroll permission
     * @return void
     */
    return function (allow, selector) {
    	if (typeof selector !== "undefined") {
	        _selector = selector;
	        _element = document.querySelector(selector);
    	}

        if (true === allow) {
        	if (false !== _element) {
	            _element.addEventListener('touchstart', captureClientY, false);
	            _element.addEventListener('touchmove', preventOverscroll, false);
        	}
            document.body.addEventListener("touchmove", preventBodyScroll, false);
        } else {
        	if (false !== _element) {
	            _element.removeEventListener('touchstart', captureClientY, false);
	            _element.removeEventListener('touchmove', preventOverscroll, false);
	        }
            document.body.removeEventListener("touchmove", preventBodyScroll, false);
        }
    };
}());

/**
 * modalEffects.js v1.0.0
 * http://www.codrops.com
 *
 * Licensed under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Copyright 2013, Codrops
 * http://www.codrops.com
 */
var ModalEffects = (function() {

	function init() {

		var overlay = document.querySelector( '.md-overlay' );

		[].slice.call( document.querySelectorAll( '[data-modal]' ) ).forEach( function( el, i ) {

			var modal = document.querySelector( '#' + el.getAttribute( 'data-modal' ) ),
				close = modal.querySelector( '.md-close' );

			function removeModal() {
				modal.classList.remove('md-show');
				document.documentElement.classList.remove('no-scroll');
				disableBodyScroll(false, '.md-content');
			}

			el.addEventListener( 'click', function( ev ) {
				modal.classList.add('md-show');
				document.documentElement.classList.add('no-scroll');
				disableBodyScroll(true, '.md-content');
				overlay.removeEventListener( 'click', removeModal );
				overlay.addEventListener( 'click', removeModal );
			});

			close.addEventListener( 'click', function( ev ) {
				ev.stopPropagation();
				removeModal();
			});

		} );

	}

	init();

})();
              
            
!
999px

Console