cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <button class="modal-open">Open modal box</button>
<div class="modal-box">
    <div class="modal-box-content">
        <ul>
            <li><a href="#">One</a></li>
            <li><a href="#">Two</a></li>
            <li><a href="#">Three</a></li>
            <li><a href="#">Four</a></li>
            <li><a href="#">Five</a></li>
        </ul>
    </div>
    <button class="modal-close"><span class="visuallyhidden">Close modal box</span></button>
</div>
            
          
!
            
              $ease: cubic-bezier(0.165, 0.84, 0.44, 1);
$highlight-color: #505050;

@mixin absolute-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

body {
    font-family: sans-serif;
    background-color: #1d1f20;
}

.modal-open {
    padding: 10px 0;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #fff;
    border: 0;
    outline: none;
    background-color: transparent;
    @include absolute-center;
    &:before,
    &:after {
        content: "";
        position: absolute;
        top: 100%;
        left: 0;
        height: 2px;
        transition: width 400ms $ease;
    }
    &:before {
        width: 100%;
        background-color: lighten($highlight-color, 30%);
    }
    &:after {
        width: 0;
        background-color: $highlight-color;
    }
    &:hover:after {
        width: calc(100% + 1px);
    }
}

.modal-box {
    position: absolute;
    overflow: hidden;
    width: 0;
    height: 2px;
    color: #fff;
    background-color: $highlight-color;
    transition: width 400ms 400ms $ease, left 400ms 400ms $ease, height 400ms 0ms $ease, top 400ms 0ms $ease;
    &.is-open {
        transition: width 400ms 0ms $ease, left 400ms 0ms $ease, height 400ms 400ms $ease, top 400ms 400ms $ease;
        li {
            opacity: 1;
        }
        .modal-close {
            opacity: 1;
            transition: all 500ms 700ms;
        }
    }
    ul {
        position: absolute;
        top: 50%;
        left: 50%;
        margin: 0;
        padding: 30px;
        list-style-type: none;
        transform: translate(-50%, -50%);
    }
    li {
        position: relative;
        margin: 20px 0;
        text-align: center;
        opacity: 0;
        transition: all 200ms;
    }
    a {
        position: relative;
        font-weight: 300;
        text-decoration: none;
        letter-spacing: 3px;
        text-transform: uppercase;
        color: #fff;
        &:before,
        &:after {
            content: "";
            position: absolute;
            top: 100%;
            left: 0;
            height: 2px;
            transition: width 400ms $ease;
        }
        &:after {
            width: 0;
            background-color: #fff;
        }
        &:hover:after {
            width: 100%;
        }
    }
    @for $i from 1 through 5 {
        &.is-open li:nth-child(#{$i}) {
            transition: all 500ms 500ms + (75ms * $i);
        }
    }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 15px;
    height: 15px;
    padding: 0;
    border: 0;
    outline: none;
    opacity: 0;
    background-color: transparent;
    transform: rotate(-45deg);
    &:before,
    &:after {
        content: "";
        display: block;
        position: absolute;
        top: 50%;
        left: 0;
        width: 15px;
        height: 3px;
        background-color: #fff;
        transform: translate(-50%, -50%);
    }
    &:after {
        width: 3px;
        height: 15px;
    }
}

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

            
          
!
            
              var $trigger = $('.modal-open');
var $close = $('.modal-close');
var $modal = $('.modal-box');

$(window).on('resize', function() {
    var top = $trigger.offset().top + $trigger.outerHeight();
    var left = $trigger.offset().left;
    var width = $trigger.outerWidth();
    $trigger.attr({
        'data-top': top,
        'data-left': left,
        'data-width': width
    });
    $modal.css({
        top: top,
        left: left
    });
}).trigger('resize');

$trigger.on('click', function() {
    $modal.css({
        top: 0,
        left: 0,
        width: '100%',
        height: '100%'
    }).addClass('is-open');
});

$close.on('click', function() {
    var top = $trigger.offset().top + $trigger.outerHeight();
    var left = $trigger.offset().left;
    $modal.css({
        top: top,
        left: left,
        width: 0,
        height: '2px'
    }).removeClass('is-open');
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console