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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <!-- overlay !-->
<div id="search" class="fade">
    <a href="#" class="close-btn" id="close-search">
        <em class="fa fa-times"></em>
    </a>
    <input placeholder="type here" id="searchbox" type="search"/>
</div>
<!--- /overlay -->
<header>
  <a id="responsive-menu-trigger" href="#nav">
            <em class="fa fa-bars"></em>
        </a>
    <nav id="nav" class="bottom">
        <ul>
            <li>
                <a href="#">Menu Item 1</a>
            </li>
            <li>
                <a href="#">Menu Item 2</a>
            </li>
            <li>
                <a href="#">Menu Item 4</a>
            </li>
            <li>
                <a href="#">Menu Item 5</a>
            </li>
            <li>
                <a href="#">Menu Item 6</a>
            </li>
        </ul>
         <a href="#" class="close-btn" id="close-menu">
            <em class="fa fa-times"></em>
        </a>
    </nav>
    <!-- trigger search with a link to an anchor -->
    <a href='#search'>
        <em class="fa fa-search"></em>
    </a>
    <!-- /trigger search with a link to an anchor -->
</header>
<main>
    <h1>CSS only fullscreen fly in search popup and responsive Menu</h1>
    <br>
    <h2>Click the search button in the top-right corner to trigger the search box</h2>
    <h2>Resize the window to trigger responsive menu</h2>
    <p>
       <br><br><br><br><br>
        Change fly-in direction:
        <a href="#" onClick="changeClass('bottom')">bottom</a>,
        <a href="#" onClick="changeClass('top')">top</a>,
        <a href="#" onClick="changeClass('left')">left</a>,
        <a href="#" onClick="changeClass('right')">right</a>,
        <a href="#" onClick="changeClass('fade')">fade only</a>
        then press search again.
    </p>
    <p>
        You can also combine the directions:
        <a href="#" onClick="changeClass('bottom left')">bottom-left</a>,
        <a href="#" onClick="changeClass('bottom right')">bottom-right</a>,
        <a href="#" onClick="changeClass('top left')">top-left</a>,
        <a href="#" onClick="changeClass('top right')">top-right</a>
    </p>
</main>
<footer>
</footer>
              
            
!

CSS

              
                
*
{
    box-sizing: border-box;
}

body
{
    background: #ededed;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

main
{
    flex: 1 0 auto;
    padding: 1rem 2rem;
}

p
{
    margin: 1em 0;
}

header
{
    background: #333;
    color: #fff;
    display: flex;
    line-height: 3rem;
    flex-direction: row;
    justify-content: space-between;
    padding: 0 2rem;
    width: 100%;
    a
    {
        &, &:active, &:visited
        {
            color: #fff;
            text-decoration: none;
        }
    }
}

/**********************/
/* Full screen search */
/**********************/

#search
{
    align-items: center;
    background: rgba(0, 0, 0, .975);
    height: 0;
    display: flex;
    justify-content: center;
    opacity: 0;
    position: fixed;
    transition: all .5s;
    width: 100vw;
    will-change: transform, opacity;
    z-index: -1;

    &:target
    {
        height: 100vh !important;
        opacity: 1;
        width: 100vw !important;
        z-index: 2;
        .close-btn
        {
            display: block;
        }
    }
}

#searchbox
{
    background: transparent;
    border: solid #fff;
    border-width: 0 0 1px 0;
    color: #fff;
    flex: 1 0 auto;
    font-size: 2rem;
    height: 2rem;
    max-width: 50%;
    outline: 0;
    padding: 2rem 1rem;
}

.close-btn
{
    display: none;
    color: #fff;
    font-size: 2rem;
    position: absolute;
    top: .5rem;
    right: 2rem;
}

/**********************/
/*   Responsive Menu  */
/*   (mobile first)   */
/**********************/

#nav
{
    position: relative;
    ul
    {
        align-items: center;
        background: rgba(0, 0, 0, .95);
        color: #fff;
        display: flex;
        flex-direction: column;
        font-size: 2rem;
        height: 0;
        justify-content: center;
        left: 0;
        margin: 0;
        opacity: 0;
        padding: 0;
        pointer-events: none;
        position: fixed;
        transition: all .5s;
        top: 0;
        will-change: opacity;
        width: 100vw;
        li
        {
            list-style: none;
            padding: 1rem 0;
        }
    }
    &:target
    {
        ul
        {
            height: 100vh !important;
            left: 0;
            opacity: 1;
            top: 0;
            width: 100vw !important;
        }
        .close-btn
        {
            display: block;
            position: fixed;
        }
    }
}

@media screen and ( min-width: 768px)
{
    #responsive-menu-trigger, #close-menu
    {
        display: none;
    }

    #nav
    {
        &, &:target
        {
            ul
            {
                background: none;
                display: inline-flex;
                flex-direction: row;
                font-size: 1rem;
                height: auto !important;
                opacity: 1;
                padding: 0;
                pointer-events: initial;
                position: static;
                transition: none;
                width: auto !important;
                li
                {
                    padding: 0;
                    a
                    {
                        text-decoration: none;
                        font-size: 1rem;
                        margin-right: 1rem;
                    }
                }
            }
            .close-btn{
                display: none;
            }
        }
    }
}

/**********************/
/* fly in directions  */
/**********************/

#search, #nav ul
{
    &.left
    {
        left: 0;
        height: 100vh;
        width: 0;
    }

    &.right
    {
        height: 100vh;
        width: 0;
        right: 0;
        left: auto !important;
    }

    &.bottom.left, &.bottom.right, &.top.left, &.top.right
    {
        height: 0;
    }

    &.bottom
    {
        bottom: 0;
        top: auto !important;
    }

    &.fade
    {
        height: 100vh;
        width: 100vw;
        transition: opacity .5s;
    }
}

              
            
!

JS

              
                //this is only for demonstration of different fly-in directions

var changeClass = function(name){
  $('#search, #nav ul').removeAttr('class').addClass(name);
}
              
            
!
999px

Console