Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <div class="player">
    <div class="vinyl"></div>
    <div class="cover">
        <div class="header">
            <div class="artist"><a href="#" target="_blank"></a></div>
            <div class="title"></div>
        </div>
        <div class="controls">
            <button class="transparent loop fi-loop"></button>
            <span>
                <button class="prev fi-previous"></button>
                <button class="play fi-play"></button>
                <button class="stop fi-stop"></button>
                <button class="next fi-next"></button>
            </span>
            <button class="transparent shuffle fi-shuffle"></button>
            <div class="progressbar">
                <div class="progress"></div>
            </div>
        </div>
    </div>
</div>
              
            
!

CSS

              
                $primary: #98c6c3; // daphne blue
$light: #f4f3ef; // artic white
$transparent: rgba(0,0,0,.8);

html, body { height: 100%; }
body{ 
    background: radial-gradient($light, $primary);
    overflow: hidden;
}

.player {
    position: absolute;
    top:50%; left:50%;
    height:260px; width:260px;
    margin: -130px 0 0 -130px;
    font-family: 'Roboto', sans-serif;
    color: $light;
    cursor: default;
    box-shadow: 0 3px 10px rgba(0,0,0,.4);
}

.vinyl {
    position: absolute;
    height: 98%; width: 98%;
    top: 1%; left: 51%;
    background: url('http://www.thebeatles.com/monovinyl/images/site/record.png') center;
    background-size: 280px 280px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    pointer-events: none;
    transition: left .8s, -webkit-transform 1.5s;
  -webkit-transform: rotate(-45deg);
       -moz-transform: rotate(-90deg);
        -ms-transform: rotate(-90deg);
         -o-transform: rotate(-90deg);
            transform: rotate(-90deg);
}
.player.playing .vinyl {
    left: 1%;
    transition: all .8s;
    -webkit-transform: rotate(0);
       -moz-transform: rotate(0);
        -ms-transform: rotate(0);
         -o-transform: rotate(0);
            transform: rotate(0);
}

.cover {
    position: absolute;
    height:100%; width:100%;
    background-color: black;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.header, .controls {
    background: $transparent;
    transition: all ease-out .3s;
}

.header {
    position: absolute;
    top: -40px;
    width:100%;
    padding: 5px;
    box-sizing: border-box;
    white-space: nowrap;
}
.header.show, 
.player:hover .header {
    top: 0px;
}

.artist, .title {
    line-height: 15px;
    text-align: center;
}
.artist {
    font-size: 13px;
    font-weight: 700;
}
.artist a {
    color: $light;
}
.title {
    font-size: 11px;
    font-weight: 300;
}

.controls {
    position: absolute;
    bottom: -40px;
    width: 100%;
    padding: 5px; 
    text-align: center;
    box-sizing: border-box;
}
.player:hover .controls {
    bottom: 0px;
}

.controls button {
    height: 30px; width: 30px;
    border: 0;
    cursor: pointer;
    font-size: 100%;
    color: $light;
    border-radius: 3px;
    box-shadow: 
        inset 1px 1px 0 rgba(255,255,255,.3),
        inset -1px -1px 0 rgba(0,0,0,.3);
    text-shadow: 0 1px 1px rgba(0,0,0,.3);
    background: linear-gradient($primary, darken($primary, 10%));
    transition: all .1s;
}
.controls button:active {
    background: linear-gradient(darken($primary, 10%), $primary);
}
.controls button:focus {
    outline: 0;
}

.controls button.transparent { 
    background: transparent;
    box-shadow: none;
    color: rgba(255,255,255,.3);
}
.controls button.active { color: $light; }
.controls button.loop { float: left; }
.controls button.shuffle { float: right; }

.progressbar {
    opacity: 0;
    position: absolute;
    bottom: 40px; left: 0;
    height: 5px;
    width: 100%;
    background: linear-gradient(
        darken($primary, 30%), 
        darken($primary, 25%),
        darken($primary, 30%));
    cursor: pointer;
    transition: opacity .2s;
}
.player.playing .progressbar {
    opacity: 1;
}

.progress {
    height: 100%;
    width: 0;
    background: $light;
    box-shadow: inset 0 0 1px darken($light, 15%);
}
              
            
!

JS

              
                var music = [
    {
        title: 'Free Four',
        artist: 'Pink Floyd',
        artistWiki: 'http://en.wikipedia.org/wiki/Pink_floyd',
        album: 'Obscured by Clouds',
        cover: 'http://upload.wikimedia.org/wikipedia/en/e/ef/Pink_Floyd_-_Obscured_by_Clouds.jpg',
        length: '5000'
    },
    {
        title: 'Iron Tusk',
        artist: 'Mastodon',
        artistWiki: 'http://en.wikipedia.org/wiki/Mastodon_(band)',
        album: 'Leviathan',
        cover: 'http://upload.wikimedia.org/wikipedia/en/c/ca/Leviathan_special_edition_cover.jpg',
        length: '5000'
    },
    {
        title: 'I Want You (She\'s So Heavy)',
        artist: 'The Beatles',
        artistWiki: 'http://en.wikipedia.org/wiki/Beatles',
        album: 'Abbey Road',
        cover: 'http://upload.wikimedia.org/wikipedia/en/4/42/Beatles_-_Abbey_Road.jpg',
        length: '5000'
    }
]

var song_id = 0;
var song = music[0];
var titleInterval = null;
var timerStart = 0;
var timerPause = 0;

function init() {
    show();
    setTimeout(function() {
        showHeader();
        play();
    }, 1000);
}

function show() {
    song = music[song_id];
    $('.artist a').html(song.artist).attr('href', song.artistWiki);
    $('.title').html(song.title);
    $('.cover').css('background-image', 'url('+song.cover+')');
}

function showHeader() {
    $('.header').addClass('show');
    setTimeout(function() { $('.header').removeClass('show'); }, 2000);
}

function togglePlay() {
    if($('.player').hasClass('playing') && !$('.player').hasClass('paused')) pause();
    else play();
}

function play() {
    show();
    $('.player').removeClass('paused').addClass('playing');
    $('.controls .play').removeClass('fi-play').addClass('fi-pause');
    startProgress();
}

function pause() {
    $('.player').addClass('paused');
    $('.controls .play').removeClass('fi-pause').addClass('fi-play');
    pauseProgress();
}

function stop() {
    $('.player').removeClass('paused').removeClass('playing');
    $('.controls .play').removeClass('fi-pause').addClass('fi-play');
    stopProgress();
    initProgress();
    song_id = 0;
    show();
}

function prev() {
    if(song_id <= 0) song_id = 0;
    else song_id--;
    
    show();
    showHeader();
    stopProgress();
    initProgress();
    if($('.player').hasClass('playing') && !$('.player').hasClass('paused')) startProgress();
}

function next() {
    if(song_id >= music.length-1) {
        stop();
    }
    else {
        song_id++;
        show();
        showHeader();
        stopProgress();
        initProgress();
        if($('.player').hasClass('playing') && !$('.player').hasClass('paused')) startProgress();
    }
}

function initProgress() {
    $('.progress').css('width', '0');
}

function startProgress() {
    if(timerStart == 0) {
        timerStart = Date.now();
        var length = parseInt(song.length);
    }
    else var length = parseInt(song.length) - (timerPause - timerStart);
    
    $('.progress').animate({ width: '100%' }, length, 'linear', next);
}

function pauseProgress() {
    $('.progress').stop();
    timerPause = Date.now();
}

function stopProgress() {
    $('.progress').stop();
    timerStart = 0;
    timerPause = 0;
}

$('.play').click(function(){ togglePlay(); });
$('.stop').click(function(){ stop(); });
$('.prev').click(function(){ prev(); });
$('.next').click(function(){ next(); });
$('.loop, .shuffle').click(function(){ 
    $(this).toggleClass('active'); 
});

init();
              
            
!
999px

Console