Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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="color-grid js-color-panel-container">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
              
            
!

CSS

              
                .color-grid {
    overflow: hidden;
    width: 600px;
    margin: 0 auto;
    div {
        -webkit-border-radius: 5px;
        -moz-border-radius:    5px;
        border-radius:         5px;
        min-width: 40px;
        min-height: 40px;
        display: inline-block;
        -webkit-transition: all .5s ease-in-out;
        -moz-transition:    all .5s ease-in-out;
        -ms-transition:     all .5s ease-in-out;
        -o-transition:      all .5s ease-in-out;
        transition:         all .5s ease-in-out
    }
}
              
            
!

JS

              
                $(document).ready(function() {
			// Colored panels parent
	var colorPanelParent = $('.js-color-panel-container'),
			// Colored panels
			colorPanels 		 = colorPanelParent.find('div'),
			// Number of colored panels
			numColorPanels	 = colorPanels.length,
			/** Max RGB val
			* 256 since the random() method returns a number
			* between 0 - 1 - including 0, but not 1.
			* This way the highest number will be 255 once
			* multiplied by the random number.
			*/ 
			rgbVal					 = 256;

	/**
	 * Color changer
	 */
	function colorChangeTimer() {
		setTimeout(function() {

			// Single panel on which to change color
			var _panelToChange = generateRandomNumber(numColorPanels - 1);

			// Change panel background color
			colorsToChange(_panelToChange);

			// Recursion
			colorChangeTimer();
		}, 150);
	}

	/**
	 * Generate random number between 0 - n.
	 * @param  {Number} ranNum: random index of panel to be changed
	 * @return {Number} (0 - n)
	 */
	function generateRandomNumber(ranNum) {
				// Highest possible number.
		var _upperLimit = ranNum,
				/**
				 * Randomized number
				 * Multiply result (greater than or equal to 0, but less than 1) by
				 * the upperLimit, then round to nearest whole number.
				 */
				result = Math.round(Math.random() * _upperLimit);

		// Return the random number for use in other functions.
		return result;
	}

	/**
	 * Change panel background color
	 * @param  {Number} index: index of color panel to be changed
	 */
	function colorsToChange(index) {
		var color1 = generateRandomNumber(rgbVal),
				color2 = generateRandomNumber(rgbVal),
				color3 = generateRandomNumber(rgbVal);
		$(colorPanels[index]).css('background-color', 'rgb(' + color1 + ', ' + color2 + ', ' + color3 + ')');
	}

	/**
	 * Loop through colorPanels and run colorsToChange()
	 * to change thier individual background colors.
	 * This occurs once on page load.
	 * @param  {Number} var i: iterator
	 */
	function changeColorsOnLoad() {
		for (var i = 0; i < numColorPanels; i++) {
			colorsToChange(i);
		};
	}

	changeColorsOnLoad();
	colorChangeTimer();
});

              
            
!
999px

Console