octocatstartv

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.

            
              - songs = ['Song 1, Daft Punk', 'Song 2, Daft Punk', 'Song 3, Daft Punk', 'Song 4, Daft Punk', 'Song 5, Daft Punk', 'Song 6, Daft Punk', 'Song 7, Daft Punk']

.app
  input(type="checkbox" id="play" checked)
  .album
  .track
    .progress
  .title Instant Crush 
    span.artist - Daft Punk
  .throbber
  label.play(for="play")
  .controls
    .control.prev
    .control.rw
    .control.fw
    .control.next
  ul.songlist
    li.song 
      .name My favorites
      .artist 102 songs
    for song in songs
      li.song 
        .cover
        .name #{song.split(',')[0]}
        .artist #{song.split(',')[1]}
        
.infopanel 
  h2 Music Player Transition
  p created from 
    a(href="https://dribbble.com/shots/1850527-Music-Player-Transition" target="_blank") this dribble shot
  p click the play/pause button to see the transition
            
          
!
            
              $colors: (
  red:(
    50:#FFEBEE,
    100:#FFCDD2,
    200:#EF9A9A,
    300:#E57373,
    400:#EF5350,
    500:#F44336,
    600:#E53935,
    700:#D32F2F,
    800:#C62828,
    900:#B71C1C,
  ),
  grey:(
    50:#FAFAFA,
    100:#FAFAFA,
    200:#EEEEEE,
    300:#E0E0E0,
    400:#BDBDBD,
    500:#9E9E9E,
    600:#757575,
    700:#616161,
    800:#424242,
    900:#212121,
  ),
  white:#fff,
  black:#000,
);
@import url(http://fonts.googleapis.com/css?family=Roboto:400,300,100,700);
@function material-color($h,$l:false) {
  @if $l {
    @return map-get(map-get($colors, $h), $l);
  }
  @else {
    @return map-get($colors, $h);
  }
}
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  list-style: none;
  backface-visibility: hidden;
}
body {
  min-height: 100vh;
  display: flex;
  background: material-color(red, 400);
  color: material-color(white);
  font-family: 'Roboto', sans-serif;
}
.infopanel {
  padding: 2em;
  h2 {
    font-size: 3em;
    font-weight: 100;
  }
  a {
    color: currentcolor;
  }
}
.app {
  position: relative;
  height: 500px;
  width: 300px;
  flex: 0 0 300px;
  background: #222;
  overflow: hidden;
  .songlist {
    position: absolute;
    top: 100%;
    height: 58%;
    left: 0;
    background: material-color(grey, 900);
    color: material-color(white);
    width: 100%;
    transition: transform 0.5s;
    transform: translate3d(0, -100%, 0);
  }
  .throbber {
    position: absolute;
    top: 42%;
    height: 3em;
    left: 0;
    margin-top: -3em;
    background: rgba(material-color(grey, 900), 0.4);
    width: 100%;
    transition: opacity 0.3s 0.4s;
    opacity: 1;
  }
  .title {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    width: 100%;
    height: 2em;
    line-height: 2em;
    text-align: center;
    color: material-color(white);
    transition: transform 0.3s 0.3s;
    transform: scale(0.7)
    translate3d(-106%,
    -8em,
    0);
    .artist {
      font-weight: 200;
    }
  }
  .song {
    padding: 0.5em;
    font-size: 0.8em;
    line-height: 2em;
    transition: all 0.5s;
    .cover {
      height: 2em;
      width: 2em;
      float: left;
      margin-left: 0.5em;
      margin-right: 0.5em;
      background-color: #000;
      background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/28359/daft.jpg);
      background-size: 100% auto;
      background-position: 50% 50%;
      background-repeat: no-repeat;
    }
    .name {
      font-size: 0.8em;
      line-height: 1.4em;
      font-weight: 700;
      margin-left: 0.5em;
    }
    .artist {
      font-size: 0.8em;
      line-height: 1.4em;
      font-weight: 200;
      margin-left: 0.5em;
    }
  }
  .track {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    pointer-events: none;
    z-index: 4;
    transform: scaley(0.7) translate3d(-73%,
    -80px,
    0);
    backface-visibility: hidden;
    box-shadow: 0 0 0 4px material-color(red,
    300);
    transition: all 0.2s;
    height: 0;
    border-radius: 0;
    padding: 0;
    &:after {
      position: absolute;
      bottom: 0;
      left: 50%;
      content: '';
      background: material-color(grey, 900);
      height: 2em;
      width: 50%;
      margin: -1.25em -25%;
      visibility: hidden;
    }
  }
  .controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    font-size: 0;
    transition: transform 0.3s;
    .control {
      position: relative;
      display: inline-block;
      padding-bottom: 25%;
      width: 25%;
      background: material-color(grey,
      900);
      &:before {
        font-size: 1rem;
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        display: block;
        height: 0;
        width: 0;
        margin: -10px;
        border: 10px solid transparent;
      }
      &:after {
        font-size: 1rem;
        position: absolute;
        top: 50%;
        left: 50%;
        display: block;
        height: 0;
        width: 0;
        margin: -10px;
        border: 10px solid transparent;
      }
      &.prev {
        &:before {
          border-right-color: material-color(grey, 400);
        }
      }
      &.next {
        &:before {
          border-left-color: material-color(grey, 400);
        }
      }
      &.fw {
        &:before {
          border-left-color: material-color(grey, 400);
          margin-left: -7px;
        }
        &:after {
          content: '';
          border-left-color: material-color(grey, 400);
          margin-left: 0;
        }
      }
      &.rw {
        &:before {
          content: '';
          border-right-color: material-color(grey, 400);
          margin-left: -13px;
        }
        &:after {
          content: '';
          border-right-color: material-color(grey, 400);
          margin-left: -20px;
        }
      }
    }
  }
  .play {
    position: absolute;
    z-index: 4;
    top: 50%;
    left: 50%;
    height: 3em;
    width: 3em;
    margin: -1.5em;
    background: material-color(red,
    500);
    border-radius: 100%;
    animation: play-out 0.5s forwards;
    transform: rotate(90deg);
    &:before,
    &:after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      margin: -0.75em -0.4em;
      border: 0 solid transparent;
      transition: all 0.25s;
    }
    &:before {
      transform: translatex(-50%) translatey(-10%);
      border-left-width: 0.8em;
      border-bottom: 1.5em solid material-color(white);
    }
    &:after {
      transform: translatex(50%) translatey(-10%);
      border-right-width: 0.8em;
      border-bottom: 1.5em solid material-color(white);
    }
  }
  .album {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    padding-bottom: 50%;
    transform: translate3d(-50%, -50%, 0);
    backface-visibility: hidden;
    border-radius: 100%;
    box-shadow: 0 0 0 300px material-color(grey, 900);
    transition: all 1s;
    background-color: #000;
    background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/28359/daft.jpg);
    background-size: 200% auto;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    animation: album-out 0.5s forwards;
  }
  #play:checked ~ {
    .album {
      animation: album-in 0.15s reverse forwards, album-spin 3s 0.15s ease-in, album-spin 1.8s 3.15s infinite linear;
    }
    .throbber {
      opacity: 0;
      transition-delay: 0;
    }
    .track {
      padding-bottom: 60%;
      border-radius: 100%;
      transform: translate3d(-50%,
      -50%,
      0);
      &:after {
        visibility: visible;
      }
    }
    .play {
      animation: play-in 0.15s reverse forwards;
      &:before {
        transform: translatex(-100%);
        border-width: 0.75em 0.15em;
        margin: -0.75em -0.15em;
        border-color: material-color(white);
      }
      &:after {
        transform: translatex(100%);
        margin: -0.75em -0.15em;
        border-width: 0.75em 0.15em;
        border-color: material-color(white);
      }
    }
    .songlist {
      transform: translate3d(0,
      0,
      0);
      .song {
        padding: 8em 0.5em;
      }
    }
    .title {
      transition-delay: 0s;
      transform: scale(1)
      translate3d(-50%, -12em, 0);
    }
  }
}
@keyframes album-out {
  0% {
    width: 50%;
    padding-bottom: 50%;
    border-radius: 100%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
  }
  30% {
    width: 100%;
    padding-bottom: 70%;
    border-radius: 100%;
    top: 0%;
    transform: translate3d(-50%, 0, 0);
  }
  60% {
    width: 100%;
    padding-bottom: 70%;
    border-radius: 0 0 50% 50%;
    top: 0%;
    transform: translate3d(-50%, 0, 0);
  }
  100% {
    width: 100%;
    padding-bottom: 70%;
    border-radius: 0;
    top: 0%;
    transform: translate3d(-50%, 0, 0);
  }
}
@keyframes album-in {
  0% {
    width: 50%;
    padding-bottom: 50%;
    border-radius: 100%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
  }
  30% {
    width: 100%;
    padding-bottom: 70%;
    border-radius: 100%;
    top: 0%;
    transform: translate3d(-50%, 0, 0);
  }
  60% {
    width: 100%;
    padding-bottom: 70%;
    border-radius: 0 0 50% 50%;
    top: 0%;
    transform: translate3d(-50%, 0, 0);
  }
  100% {
    width: 100%;
    padding-bottom: 70%;
    border-radius: 0;
    top: 0%;
    transform: translate3d(-50%, 0, 0);
  }
}
@keyframes album-spin {
  0% {
    transform: translate3d(-50%, -50%, 0)
    rotate(0);
  }
  100% {
    transform: translate3d(-50%, -50%, 0)
    rotate(360deg);
  }
}
@keyframes play-out {
  0% {
    top: 50%;
    left: 50%;
    transform: rotate(360deg);
  }
  30% {
    top: 42%;
    left: 50%;
  }
  60% {
    top: 42%;
    left: 84%;
  }
  100% {
    top: 42%;
    left: 84%;
    transform: rotate(90deg);
  }
}
@keyframes play-in {
  0% {
    top: 50%;
    left: 50%;
    transform: rotate(360deg);
  }
  30% {
    top: 42%;
    left: 50%;
  }
  60% {
    top: 42%;
    left: 84%;
  }
  100% {
    top: 42%;
    left: 84%;
    transform: rotate(90deg);
  }
}
            
          
!
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