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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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>Dynamic color generation with SASS</h1>

<h2>Additive Gradation</h2>
<ul class="additive">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h2>Multiplicative Gradation</h2>
<ul class="multiplicative">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h2>Exponential Gradation</h2>
<ul class="exponential">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h2>Additive Hue</h2>
<ul class="additive hue">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h2>Multiplicative Hue</h2>
<ul class="multiplicative hue">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h2>Exponential Hue</h2>
<ul class="exponential hue">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h2>Degree-based Hue</h2>
<ul class="degree hue">
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
  <li class="button"></li>
</ul>

<h1>Huge hat tip to <a href="https://codepen.io/Ant1n/pen/vERBxX">Ant1n's Pen</a> that set this all in motion!</h1>

<h2>Full write up and explanation on <a href="http://mpinto.org/writing/using-sass-to-generate-colors-dynamically">mpinto.org</a></h2>
            
          
!
            
              /* set a base color, any color you like */
$base-color: rgb(239, 109, 172);

/* how many units do you want to loop through? can't exceed max number of elements in the child group */
$gradiated-buttons-count: 10; 

/*  Adjust this number to increase or decrease the strength of the color function */
$strength: 5; 

/* degrees - used for hue adjustment */
$degrees: 20deg;

/* Loop through the 'child' elements of our selected element, using nth-child, incrementally. This color effect is multiplicative - it will multiply the strength variable by the increment number to darken the base color accordingly */

@for $i from 0 to $gradiated-buttons-count {
      ul.multiplicative .button:nth-child(#{$i}) {
      background-color: darken($base-color, $i*$strength);
    }
  }

/* additive - add the strength variable to the increment number to darken the base color accordingly */

@for $i from 0 to $gradiated-buttons-count {
      ul.additive .button:nth-child(#{$i}) {
      background-color: darken($base-color, $i+$strength);
    }
  }

/* exponential  - multiply the increment variable by itself to darken the base color accordingly */

@for $i from 0 to $gradiated-buttons-count {
      ul.exponential .button:nth-child(#{$i}) {
      background-color: darken($base-color, $i*$i);
    }
  }

/* exponential hue  - multiply the increment variable by itself to darken the base color accordingly */

@for $i from 0 to $gradiated-buttons-count {
      ul.exponential.hue .button:nth-child(#{$i}) {
      background-color: adjust-hue($base-color, $i*$i);
    }
  }

/* multiplicative hue   */

@for $i from 0 to $gradiated-buttons-count {
      ul.multiplicative.hue .button:nth-child(#{$i}) {
      background-color: adjust-hue($base-color, $i*$strength);
    }
  }

/* additive hue  */

@for $i from 0 to $gradiated-buttons-count {
      ul.additive.hue .button:nth-child(#{$i}) {
      background-color: adjust-hue($base-color, $i+$strength);
    }
  }

/* degree based hue - play with the degrees variable. multiplying beyond 360 causes the colors to repeat! */

@for $i from 0 to $gradiated-buttons-count {
      ul.degree.hue .button:nth-child(#{$i}) {
      background-color: adjust-hue($base-color, $degrees*$i);
    }
  }

/* Just a wee bit of base styling to make this look decent. */

body {
  padding: 3%;
  font-family: Roboto, Arial, Sans-serif;
  color: $base-color;
}

h1 {
  font-size: 4.5vw;
  margin-top: none;
  color: darken( $base-color, 30% );
  font-weight: lighter;
}

h1, h2 {
  margin-left: 3.5%;
}

h2 {
   margin-top: 2em;
}

ul li {
  display: block;
  width: 96%;;
  height: 9vh;
}
            
          
!
            
              // thanks to Ant1n's Pen for the basic SASS looping function. https://codepen.io/Ant1n/pen/vERBxX //
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console