cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console