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

              
                <div class="rating" data-rating="70" data-height="48">

	<div class="overlay">

		<svg version="1.1" class="gridicon gridicons-star" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star"><polygon points="12,2 14.582,8.953 22,9.257 16.178,13.859 18.18,21 12,16.891 5.82,21 7.822,13.859 2,9.257 9.418,8.953"/></g></svg>
		  
		<svg version="1.1" class="gridicon gridicons-star" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star"><polygon points="12,2 14.582,8.953 22,9.257 16.178,13.859 18.18,21 12,16.891 5.82,21 7.822,13.859 2,9.257 9.418,8.953"/></g></svg>
		  
		<svg version="1.1" class="gridicon gridicons-star" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star"><polygon points="12,2 14.582,8.953 22,9.257 16.178,13.859 18.18,21 12,16.891 5.82,21 7.822,13.859 2,9.257 9.418,8.953"/></g></svg>
		
		<svg version="1.1" class="gridicon gridicons-star" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star"><polygon points="12,2 14.582,8.953 22,9.257 16.178,13.859 18.18,21 12,16.891 5.82,21 7.822,13.859 2,9.257 9.418,8.953"/></g></svg>
		  
		<svg version="1.1" class="gridicon gridicons-star" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star"><polygon points="12,2 14.582,8.953 22,9.257 16.178,13.859 18.18,21 12,16.891 5.82,21 7.822,13.859 2,9.257 9.418,8.953"/></g></svg>

	</div>

	<div class="stars-outline">

		<svg version="1.1" class="gridicon gridicons-star-outline outline-5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star-outline"><path d="M12,6.308l1.176,3.167l0.347,0.936l0.997,0.041l3.374,0.139l-2.647,2.092l-0.784,0.62l0.27,0.962l0.911,3.249l-2.814-1.871 L12,15.09l-0.83,0.552l-2.814,1.871l0.911-3.249l0.27-0.962l-0.784-0.62L6.105,10.59l3.374-0.139l0.997-0.041l0.347-0.936L12,6.308 M12,2L9.418,8.953L2,9.257l5.822,4.602L5.82,21L12,16.891L18.18,21l-2.002-7.141L22,9.257l-7.418-0.305L12,2L12,2z"/></g></svg>

		<svg version="1.1" class="gridicon gridicons-star-outline outline-4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star-outline"><path d="M12,6.308l1.176,3.167l0.347,0.936l0.997,0.041l3.374,0.139l-2.647,2.092l-0.784,0.62l0.27,0.962l0.911,3.249l-2.814-1.871 L12,15.09l-0.83,0.552l-2.814,1.871l0.911-3.249l0.27-0.962l-0.784-0.62L6.105,10.59l3.374-0.139l0.997-0.041l0.347-0.936L12,6.308 M12,2L9.418,8.953L2,9.257l5.822,4.602L5.82,21L12,16.891L18.18,21l-2.002-7.141L22,9.257l-7.418-0.305L12,2L12,2z"/></g></svg>

		<svg version="1.1" class="gridicon gridicons-star-outline outline-3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star-outline"><path d="M12,6.308l1.176,3.167l0.347,0.936l0.997,0.041l3.374,0.139l-2.647,2.092l-0.784,0.62l0.27,0.962l0.911,3.249l-2.814-1.871 L12,15.09l-0.83,0.552l-2.814,1.871l0.911-3.249l0.27-0.962l-0.784-0.62L6.105,10.59l3.374-0.139l0.997-0.041l0.347-0.936L12,6.308 M12,2L9.418,8.953L2,9.257l5.822,4.602L5.82,21L12,16.891L18.18,21l-2.002-7.141L22,9.257l-7.418-0.305L12,2L12,2z"/></g></svg>

		<svg version="1.1" class="gridicon gridicons-star-outline outline-2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star-outline"><path d="M12,6.308l1.176,3.167l0.347,0.936l0.997,0.041l3.374,0.139l-2.647,2.092l-0.784,0.62l0.27,0.962l0.911,3.249l-2.814-1.871 L12,15.09l-0.83,0.552l-2.814,1.871l0.911-3.249l0.27-0.962l-0.784-0.62L6.105,10.59l3.374-0.139l0.997-0.041l0.347-0.936L12,6.308 M12,2L9.418,8.953L2,9.257l5.822,4.602L5.82,21L12,16.891L18.18,21l-2.002-7.141L22,9.257l-7.418-0.305L12,2L12,2z"/></g></svg>

		<svg version="1.1" class="gridicon gridicons-star-outline outline-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve"><g id="star-outline"><path d="M12,6.308l1.176,3.167l0.347,0.936l0.997,0.041l3.374,0.139l-2.647,2.092l-0.784,0.62l0.27,0.962l0.911,3.249l-2.814-1.871 L12,15.09l-0.83,0.552l-2.814,1.871l0.911-3.249l0.27-0.962l-0.784-0.62L6.105,10.59l3.374-0.139l0.997-0.041l0.347-0.936L12,6.308 M12,2L9.418,8.953L2,9.257l5.822,4.602L5.82,21L12,16.891L18.18,21l-2.002-7.141L22,9.257l-7.418-0.305L12,2L12,2z"/></g></svg>

	</div>

</div>
              
            
!

CSS

              
                //
// This is a proposed replacement for Noticons used in 
// https://github.com/Automattic/wp-calypso/tree/master/client/components/rating
// and uses gridicon outline stars which are overlaid and clipped with solid
// stars. Discussion here: https://github.com/Automattic/gridicons/pull/249
//  
// Notes: Rounds the rating to the nearest 10, and changes the color of empty
// outline stars.
//

// some settings to change/test
$height: 48px;
$rating: 70;

// colors
$gray: #87a6bc;
$blue: #0087be;

// round the rating to the nearest 10 
$rating: round($rating / 10) * 10;

// the outline-stars need to be a different color
@mixin outline-grey( $rating ) {
  $inverse-rating: 100 - $rating;
  @if $inverse-rating / 20 >= 1 {
    // need an integer to make this work
    $count: floor($inverse-rating / 20);
    // add a color class to only those stars outside the rating
    @for $i from 1 through $count {
      .gridicon.outline-#{$i} {
        fill: lighten( $gray, 20% );
      }  
    }
  }
}

// set the component width
$width: $height * 5;

// set the mask position from the right edge
$mask-position: ( ( $rating / 100 ) * $width );
$clip-path-mask-position: ( $width - ( ( $rating / 100 ) * $width ) );

// and the rest of the css
.rating {
  height: $height;
  position: relative;
  width: $width;
  
  .overlay,
  .stars-outline {
    display: flex;  
    height: $height;
    left: 0;
    position: absolute;
    top: 0;
  }

  .overlay {
    -webkit-clip-path: inset(0 $clip-path-mask-position 0 0);
    clip-path: inset(0 $clip-path-mask-position 0 0);
    clip: rect(0, $mask-position, $height, 0);
  }

  .gridicon {
    fill: $blue;
    width: $height;
  }

  @include outline-grey( $rating );
}
              
            
!

JS

              
                
              
            
!
999px

Console