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 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

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 inner
  - for (var i = 0; i < 6; i++)
    .side
  - for (var i = 0; i < 6; i++)
    .filling

button.light Toggle light

.container

  .cuboid.lying(style="margin-top: 140px", value="0", data-color="rgba(220, 40, 20, 0.4)")

    +inner

  .cuboid.standing(value="25", data-color="rgba(240, 170, 20, 0.4)")
  
    +inner

  .cuboid.lying(style="margin-top: 140px", value="50", data-color="rgba(230, 220, 20, 0.4)")
  
    +inner

  .cuboid.standing(value="75")
  
    +inner

  .cuboid.lying(style="margin-top: 140px", value="100", data-color="rgba(120, 200, 220, 0.4)")
  
    +inner
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Open+Sans)

$width: 40px
$height: 200px
$glow: $width / 2

html
  background: #eee
  height: 100%
  background: linear-gradient(#ccc, #aaa)
  
  &.dark
    background: linear-gradient(#444, #222)
    
.light
  background: rgba(0, 0, 0, 0.1)
  border: solid 1px white
  padding: 10px 20px
  font-family: "Open Sans"
  font-size: 14px
  cursor: pointer
  color: #666
  
  &:hover 
    background: rgba(255, 255, 255, 0.1)
  
.container
  margin: 0 auto
  width: 900px
  
  & > div 
    float: left
    margin: 70px
    
  &:after
    clear: both
    display: block
    content: ""

.cuboid 
  width: $width
  height: $height
  position: relative
  transform-style: preserve-3d
  transform-origin: ($width / 2) ($height / 2) 0
  
  .side
    box-shadow: inset 0 0 $width rgba(0, 0, 0, 0.1)
    height: 100%
    width: $width
    position: absolute
    left: 0
    top: 0
    
    &:nth-of-type(5), &:nth-of-type(6)
      height: $width
    
  .filling
    color: rgba(0, 0, 0, 0)
    box-shadow: 0 0 $glow 3px
    height: 0px
    width: $width
    position: absolute
    left: 0
    bottom: 0
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1)
    
    &:nth-of-type(11), &:nth-of-type(12)
      height: $width
      visibility: hidden
      box-shadow: 0 0 0 0
    
  .side:nth-of-type(1), .filling:nth-of-type(7)
    transform: translateZ($width / 2) rotateZ(180deg)
  .side:nth-of-type(2), .filling:nth-of-type(8)
    transform: translateX(-$width / 2) rotateY(90deg) rotateZ(180deg)
  .side:nth-of-type(3), .filling:nth-of-type(9)
    transform: translateX($width / 2) rotateY(-90deg) rotateZ(180deg)
  .side:nth-of-type(4), .filling:nth-of-type(10)
    transform: translateZ(-$width / 2)  rotateZ(180deg)
  .side:nth-of-type(5)
    transform: rotateX(90deg) translateZ($width / 2)
  .side:nth-of-type(6)
    transform: translateY($height) rotateX(90deg) translateZ($width / 2)
  .filling:nth-of-type(11)
    transform: rotateX(90deg) translateZ(-$width / 2)
  .filling:nth-of-type(12)
    transform: rotateX(90deg) translateZ(-$width / 2)
    
.cuboid.standing
  transform: rotateX(20deg) rotateY(45deg)
  
  .side:nth-of-type(6)
    box-shadow: 4px -4px 12px rgba(0, 0, 0, 0.2)
    
.cuboid.lying
  transform: perspective(500px) rotateZ(90deg) rotateY(25deg)
  
  .side:nth-of-type(3)
    box-shadow: -6px 0px 12px rgba(0, 0, 0, 0.2)
              
            
!

JS

              
                /*
  HOW TO USE:
  Fill an element ".cuboid" and ".lying" or ".standing" with 
  six ".side" and six ".filling" elements. 
  By setting the "value" and "data-color" parameters you 
  can customize your bar.
  
  The script will automatically fill your bar with your 
  value and color on page load. To update the bar simply 
  call the "updateCuboid" function with your element.
*/

var updateCuboid = function(cuboid) {
 
    var value   = parseInt(cuboid.attr("value")), 
        color   = cuboid.attr("data-color") 
                || "rgba(120, 200, 20, 0.4)", 
        height  = cuboid.height(), 
        width   = cuboid.width();
    
    if (value > 0) {
      
      $(cuboid.find(".filling")).slice(0, 4).css({
        height: value + "%",
        backgroundColor: color, 
        color: color,
      });
      
      var y           = height * (value / 100), 
          rotate      = "rotateX(90deg)", 
          translateZ1 = "translateZ(" + (-width * 0.5) 
                      + "px)",
          translateZ2 = "translateZ(" + y + "px)", 
          top         = rotate + " " + translateZ1 
                      + " " + translateZ2, 
          bottom      = rotate 
                      + translateZ1;
      
      $(cuboid.find(".filling")[4]).css({
        backgroundColor: color,
        color: color,
        visibility: "visible", 
        transform: top
      });

      $(cuboid.find(".filling")[5]).css({
        backgroundColor: color,
        color: color,
        visibility: "visible", 
        transform: bottom
      });
    }
  };

$(document).ready(function() {
  
  var cuboids = $(".cuboid");

  for (var i = 0, len = cuboids.length; i < len; i++) {

    var cuboid  = $(cuboids[i]);
    updateCuboid(cuboid);
  }
  
  setInterval(function() {
    
    for (var i = 0; i < cuboids.length; i++) {
      
      cuboids.eq(i).attr("value", Math.random() * 100);
      updateCuboid(cuboids.eq(i));
    }
  }, 2000);
});

$(".light").on("click", function(event) {
  
  $("html").toggleClass("dark");
});
              
            
!
999px

Console