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-wrapper">
  <h4>Rate this Product</h4>
  <div class="rating">
    <span data-rating="5" class="star"></span><span data-rating="4" class="star"></span><span data-rating="3" class="star"></span><span data-rating="2" class="star"></span><span data-rating="1" class="star"></span>
              body {
  background: #d9d9d9;

body, html {
  height: 100%;
  min-height: 100%;

h4 {
  font-size: 16px;
  margin: 10px 0 5px;

.rating-wrapper {
  position: fixed;
  top: 25%;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0 auto;

  width: 175px;
  height: 65px;

  background: #fff;
  padding: 20px 60px;

// this is what you're looking for, the other stuff is just for this demo
.rating {
  direction: rtl;
  font-size: 30px;
  text-align: left;
  > .star {
    font-family: FontAwesome;
    font-weight: normal;
    font-style: normal;
    display: inline-block;
    position: relative;
    padding-right: 5px;
    cursor: pointer;
    &:before {
      content: '\f006';
    &:hover ~ .star:before,
    &.selected ~ .star:before {
      color: goldenrod;
      content: '\f005';
              (function($) {
  var $stars = $('.rating .star');
  $stars.each(function() {
    var $this = $(this);
    var rating = $this.data('rating');
    $this.on('click', function(e) {
      // Prevent from selecting multiple times, or in our case
      // running an ajax request more than once for the same
      // value
      if($this.hasClass('selected')) {
        alert('you\'ve already selected this, but thanks for trying again!');
        return false;
      // $.ajax(...);
      // This is only a test so you can see it working
      alert('You selected a star rating of: ' + rating);
Loading ..................