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

              
                
mixin icon(size)
  li.nav__item
    svg(
      xlmns="http://www.w3.org/2000/svg"
      width=size
      height=size
      fill="none"
      stroke="currentColor"
      stroke-width="2"
      stroke-linecap="round"
      stroke-linejoin="round"
    )
      block

.iphone
  .container
    ul.nav
      
      +icon( 24 )
        path(d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z")
        polyline(points="22,6 12,13 2,6")

      +icon( 24 )
        path(d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z")
        circle(cx="12" cy="13" r="4")

      +icon( 24 )
        path(d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z")

      +icon( 24 )
        path(d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z")

      +icon( 24 )
        path(d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z")
        line(x1="16" y1="8" x2="2" y2="22")
        line( x1="17.5" y1="15" x2="9" y2="15")
       
    .jelly.left
       
label
  input( type="checkbox" checked )
  | solid background?
  
p
  | Inspired by 
  a=" @sergey "
  | over on dribbble. <3
                
                
//- <div class="iphone">

//-     <div class="container">

//-         <ul class="nav">
//-             <li class="nav__item">
//-                 <svg
//-                   xmlns="http://www.w3.org/2000/svg"
//-                   width="24"
//-                   height="24"
//-                   viewBox="0 0 24 24"
//-                   fill="none"
//-                   stroke="currentColor"
//-                   stroke-width="2"
//-                   stroke-linecap="round"
//-                   stroke-linejoin="round">
                 
//-             </svg></li>
//-             <li class="nav__item"><i class="icon-camera"></i></li>
//-             <li class="nav__item"><i class="icon-link"></i></li>
//-             <li class="nav__item"><i class="icon-speech-bubble"></i></li>
//-             <li class="nav__item"><i class="icon-cog"></i></li>
//-         </ul>

//-         <div class="jelly left">
//-         </div>

//-     </div>
//- </div>

//- <label><input type="checkbox" checked>
//-     use a solid background</label>

//- <p>Inspired by <a href="https://dribbble.com/shots/2071319-GIF-of-the-Tapbar-Interactions">@Sergey</a> over on dribbble. &lt;3</p>

//- <p>note: this will only work on http://</p>
              
            
!

CSS

              
                $first: cubic-bezier(.94,.12,.29,.92);
$second: cubic-bezier(.24,.84,.53,1);

$c1: #3498db;
$c2: #1abc9c;
$c3: #e75c56;
$c4: #fabb74;
$c5: #de6596;

$w: 348px;
$h: 50px;

body { 
    background: #423852;
    overflow: hidden;
}

.container {
    
    position: absolute;
    width: $w - 2;
    height: $h;
    margin-left: -$w*0.5;
    top: 41px;
    left: 50%;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
    z-index: 1;
    transform: translateX(1px);
    
    .nav * {
        user-select: none;
    }
    
    .nav,
    .nav__item {
        padding:0;
        margin: 0;
        list-style: none;
        text-align: center;
    }
    
    .nav {
        display: flex;
        background: #3c454a;
        z-index: 1;
    }
    
    .nav__item {
        
        flex-grow: 1;
        width: 60px;
        padding: 0.8em 0;
        color: rgba(255,255,255,0.5);
        z-index: 3;
        cursor: pointer;
        transition: color 0.4s ease 0.4s;
        
        i {
            font-size: 1.4em;
            font-weight: 100;
            height: $h;
        }
        
        &.selected,
        &:hover {
            color: rgba(255,255,255,1);
        }
        
        &:hover {
            transition: color 0.2s ease;
        }
        
    }

}

.jelly {
    
    background-image: 
        linear-gradient(to right, 
            $c1 0%, $c1 20%,
            $c2 20%, $c2 40%,
            $c3 40%, $c3 60%,
            $c4 60%, $c4 80%,
            $c5 80%, $c5 100%);

    background-attachment: fixed;
    background-position: 50%;
    background-size: $w;

    height: $h;
    top: 0;
    position: absolute;
    transform: translate3d(0px, 0px, 1px);
    transition:
        background 0.1s $first,
        left 0.1s $second,
        right 0.1s $second;
    
    
    &.left {
        transition: 
            background 0.6s $first,
            left 0.6s $first,
            right 0.3s $second 0.35s;
    }
 
    &.right {
        transition:
            background 0.6s $first,
            right 0.6s $first,
            left 0.3s $second 0.35s;
    }
    
}


.iphone {
    background: url(https://2.bp.blogspot.com/-6hlrTw0hxdQ/VA9aSOz9Y1I/AAAAAAAAkXE/BekM0IzyPrU/s1600/Imagenes%2Biphone%2B6%2Bpng%2B3.png);
    background-position: 1px bottom;
    background-size: cover;
    width: 801px;
    height: 200px;
    position: absolute;
    left: 50%;
    margin-left: -400px;
}

label {
    color:white;
    font-family: ubuntu;
    font-weight: 100;
    position: absolute;
    left: 50%;
    top: 20px;
    margin-left: 100px;
    width: 400px;
    text-align: center;
    line-height: 40px;
    vertical-align: middle;
    
    input {
        position: relative;
        top: 2px;
        margin: 5px;
    }
}

p {
    
    font-family: ubuntu;
    font-weight: 100;
    position: absolute;
    width: 100%;
    text-align: center;
    top: 200px;
    color: #e8dbff;
    
    a { 
        color: #6be1ff; 
        font-weight: bold;
    }
    
    &:last-of-type {
        top: 230px;
        font-style: italic;
    }
    
}

@import url(https://fonts.googleapis.com/css?family=Ubuntu:300,500);
              
            
!

JS

              
                var w = $(".container li").first().width();
//var h = $(".container li").first().outerHeight();

var move = function(x) {
	
    if( $.type(x) === "number" ) {
        var l = x;
    } else if( x instanceof $ ) {
        var l = x.position().left;
    } else {
        l = 0;
    }

    var r = $(".container").width() - (w + l);
    var original = $(".jelly").position().left;
    var dir = "right";

    $(".jelly").removeClass("left right");

    if( l < original ) {
        dir = "left";
    }
    
    $(".jelly")
        .addClass( dir )
        .css("left", l )
        .css("right", r );
        
	$(x)
        .addClass("selected")
        .siblings()
        .removeClass("selected");

}

var p = 1;
move($(".nav__item").eq(0));
var ii = setInterval(function() {
   if(p>=5){p=0;}
	move($(".nav__item").eq(p));
    p++;
},2000);

$("ul > li").on("click", function() {
    
    clearInterval(ii);
	move($(this));
	
});

//$(".jelly").css("height", h );


$("input[type=checkbox]").on("change", function() {
   
    if($(this).is(":checked")) {
        $(".jelly").css("background", "#1abc9c");
    } else {
        $(".jelly").css("background", "");
    }
    
}).trigger("change");

              
            
!
999px

Console