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.

            
              <div class="container-fluid">
  <h1 class="title">Random Spotify Covers <span>click anywhere to regenerate</span></h1>
  <div class="rand-covers row">
  </div>
</div>

<script id="cover" type="text/html">
  <div class="cover col-lg-2 col-sm-3 col-xs-3">
    <img src="{{src}}">
  </div>
</script>
            
          
!
            
              /* bootstrap is included */
body{
  background : black;
  cursor : pointer;
}
.title{
  color : white;
  position : fixed;
  top: 30px;
  left : 0px;
  padding-left : 30px;
  padding-top : 10px;
  padding-bottom : 10px;
  z-index : 1000;
  width : 100%;
  background : rgba(0,0,0,0.7);
  text-shadow : 0px 0px 10px black,
                0px 0px 10px black;
    
}
.title span{
  font-size : 18px;
}
.cover{
  padding-left : 0px;
  padding-right : 0px; 
}
.cover img{
  width : 100%; 
}
            
          
!
            
              $ ->
  
  class RandomCovers
        
    constructor : ->
      @alph = "abcdefghijklmnopqrstuvwxyz1234567890".split ""
      @randCovers = $ ".rand-covers"
      @tmpl = Mustache.compile $("#cover").html()
       
      @randomAlbums()
      
      
     randomAlbums : =>
       a = @alph[parseInt(@alph.length * Math.random())]
       b = @alph[parseInt(@alph.length * Math.random())]

       @randCovers.html ""
       $.get "https://api.spotify.com/v1/search?q=#{a}*%20%20#{b}*&type=album", @renderAlbums

       return
       

      
     renderAlbums : (d) =>
       items = d.albums.items

       for item in items
          img = item.images[1]
          if img.height ==  300 and img.width == 300 
            url = img.url
            url = url.replace "http://i.scdn.co/", "http://o.scdn.co/"
            
            $(@tmpl src : url).appendTo @randCovers
          
       return
          
          
  randomCovers = new RandomCovers();
  $(document).click randomCovers.randomAlbums
  
            
          
!
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