cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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="rating-histogram">
  <div class="rating-bar-container five" data-id="5">
    <span class="bar-label"> 5 </span>
    <span class="bar"></span>
    <span class="bar-number"></span>
  <div class="rating-bar-container four" data-id="4">
    <span class="bar-label"> 4 </span>
    <span class="bar"></span>
    <span class="bar-number"></span> 
  <div class="rating-bar-container three" data-id="3">
    <span class="bar-label"> 3 </span>
    <span class="bar"></span>
    <span class="bar-number"></span>
  <div class="rating-bar-container two" data-id="2">
    <span class="bar-label"> 2 </span>
    <span class="bar"></span>
    <span class="bar-number"></span> 
  <div class="rating-bar-container one" data-id="1">
    <span class="bar-label"> 1 </span>
    <span class="bar"></span>
    <span class="bar-number"></span>
</div><!-- /rating-histogram -->

<div class="hidden"><!-- needs for jquery calculations -->
    <input type="text" class="reviews_1star" value="5">
    <input type="text" class="reviews_2star" value="4">
    <input type="text" class="reviews_3star" value="2">
    <input type="text" class="reviews_4star" value="6">
    <input type="text" class="reviews_5star" value="3">
</div><!-- /hidden -->
              .rating-histogram {
  padding: 5px 5px 5px 44px;
  text-align: left;
  width: 100%;

.rating-histogram .rating-bar-container {
  position: relative;
  margin-bottom: 5px;

.rating-histogram .bar-label {
  margin-right: 10px;
  position: absolute;
  left: -44px;
  top: 2px;

.rating-histogram .bar-label:before {
  content: "\f005";
  font-family: FontAwesome;
  font-size: 16px;
  line-height: 16px;
  height: 16px;
  width: 16px;
  color: #ccc;
  display: inline-block;
  margin-right: 5px;

.rating-histogram .bar {
  background-color: #8e70af;
  background-image: -webkit-linear-gradient(left, #8e70af, #48bfed);
  background-image: linear-gradient(to right, #8e70af, #48bfed);
  -webkit-transition: width 2s ease;
  -moz-transition: width 2s ease;
  transition: width 2s ease;
  opacity: .8;
  display: inline-block;
  vertical-align: middle;
  width: 1%;
  height: 15px;
  margin-right: 3px;

.rating-histogram .bar-number {
  font-size: 14px;
  line-height: 1;
  vertical-align: middle;

.hidden {
  display: none;
              $(function() {
  var stars = new Array();
  var sum = 0;
  var width = new Array();

  for ( var i = 1; i < 6; i++ ) {

  for ( var i = 0; i < stars.length; i++ ) {
    sum += stars[i];       

  for ( var i = 0; i < stars.length; i++ ) {
    w = ((stars[i]) / sum * 100).toFixed(0);
    $('.rating-bar-container[data-id='+(i+1)+'] .bar').css('width', w+'%' ); 

  if (sum > 0) {
    for ( var i = 0; i < stars.length; i++ ) {
      $('.rating-bar-container[data-id='+(i+1)+'] .bar-number').html(width[i]+'%'); 
  } else{
    $(".rating-bar-container .bar-number").html('0%')

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.


Loading ..................