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.

            
              body {background-color: #234}

#music-bars span {
  background-color: #fff;
  display: block;
  width: 1px;
  float: left;
  margin-right: 2px;
}
            
          
!
            
              /* While it does *crash* the console while inspecting element (because of all the height and margin changes done inline on each span), there are no performance issues on user-side */


function equalizer(bar) {
  // Syntax: Math.random() * (max-min = range) + min;
  // My bars will be at least 70px, and at most 170px tall
  var height = Math.random() * 100 + 70;
  // Any timing would do the trick, mine is height times 7.5 to get a speedy yet bouncy vibe
  var timing = height * 7.5;
  // If you need to align them on a baseline, just remove this line and also the "marginTop: marg" from the "animate"
  var marg = (170 - height) / 2;
  
  bar.animate({
      height: height,
      marginTop: marg
  }, timing, function() {
      equalizer($(this));
  });
}

// Action on play-pause buttons can be added here (should be a wholesome function rather than annonymous)
$('#music-bars span').each(function(i) {
  equalizer($(this));
});
            
          
!
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