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.

            
              <h1>Dadgumit, Blowouts</h1>

<p>Sass' <code>lighten()</code> and <code>darken()</code> color functions can quickly blow out a color all the way to black or white. <code>mix()</code> allows more subtle color tinting or shading.</p>

<table class="C6538C">
  <tr>
    <td></td>
    <td>10%</td>
    <td>20%</td>
    <td>30%</td>
    <td>40%</td>
    <td>50%</td>
    <td>60%</td>
    <td>70%</td>
    <td>80%</td>
    <td>90%</td>
    <td>100%</td>
  </tr>
  <tr class="lighten">
    <td>lighten()</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
  <tr class="mix-l">
    <td>mix() w/ white</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
  <tr class="darken">
    <td>darken()</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
  <tr class="mix-d">
    <td>mix() w/ dark</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
</table>

<table class="FF5F00">
  <tr>
    <td></td>
    <td>10%</td>
    <td>20%</td>
    <td>30%</td>
    <td>40%</td>
    <td>50%</td>
    <td>60%</td>
    <td>70%</td>
    <td>80%</td>
    <td>90%</td>
    <td>100%</td>
  </tr>
  <tr class="lighten">
    <td>lighten()</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
  <tr class="mix-l">
    <td>mix() w/ white</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
  <tr class="darken">
    <td>darken()</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
  <tr class="mix-d">
    <td>mix() w/ dark</td>
    <td class="x10">10%</td>
    <td class="x20">20%</td>
    <td class="x30">30%</td>
    <td class="x40">40%</td>
    <td class="x50">50%</td>
    <td class="x60">60%</td>
    <td class="x70">70%</td>
    <td class="x80">80%</td>
    <td class="x90">90%</td>
    <td class="x100">100%</td>
  </tr>
</table>

<p>This demo uses Sass loops and variable interpolation to programmatically generate the background colors for the table cells. Also there's a bit of JavaScript which populates the table cells with their actual background colors. If you change the table's base color values, do re-run the JavaScript or the color values will be wrong.</p>
            
          
!
            
              $pink: #C6538C;
$orange: #FF5F00;
// $pink: invert(#C6538C);
// $orange: invert(#FF5F00);

table {
  border: 1px solid black;
  border-collapse: collapse;
  font-weight: bold;
  text-align: center;
  color: white;
  tr.darken, tr.mix-d { 
    color: black;
    & td:hover { color: white; }
  }
  td { 
    border: 1px solid black;
    padding: .4rem;
    width: 4rem;
    &:hover { color: black; }
    &:first-child { white-space: nowrap; }
  }
}

table.C6538C {
  background-color: $pink;

  tr.lighten {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: lighten($pink, $i); }
      }
    }
  }

  tr.darken {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: darken($pink, $i); }
      }
    }
  }
  
  tr.mix-l {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: mix(white, $pink, $i); }
      }
    }
  }

  tr.mix-d {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: mix(black, $pink, $i); }
      }
    }
  }

}

table.FF5F00 {
  background-color: $orange;

  tr.lighten {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: lighten($orange, $i); }
      }
    }
  }
  
  tr.darken {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: darken($orange, $i); }
      }
    }
  }

  tr.mix-l {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: mix(white, $orange, $i); }
      }
    }
  }

  tr.mix-d {
    td {
      $i: 0;
      @while $i < 100 {
        $i: $i + 10;
        &.x#{$i} { background-color: mix(black, $orange, $i); }
      }
    }
  }

}
            
          
!
            
              $("tr:nth-child(1n+2) td:nth-child(1n+2)").text(function() {
  color = $(this).css("backgroundColor");
  bg = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  function hex(x) {
    return ("0" + parseInt(x).toString(16)).slice(-2);
  }
  return "#" + hex(bg[1]) + hex(bg[2]) + hex(bg[3]);
});

/*
http://stackoverflow.com/questions/25953758/how-to-set-contents-to-background-color#25953764
http://stackoverflow.com/questions/6177454/can-i-force-jquery-cssbackgroundcolor-returns-on-hexadecimal-format
*/
            
          
!
999px
Loading ..................

Console