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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <h1>This requires sassy-maps</h1>
<p>The error is caused by the lack of sassy-maps</p>



                @import "compass/css3";

// some placeholder values
$z-indexs: (
  floor_1: 1,
  floor_2: 50,
  floor_3: 100,
  floor_4: 150,
  floor_5: 200,
  floor_6: 300,
  floor_7: 350,
  floor_8: 400,
  floor_9: 450,
  floor_10: 500

// create a hidden extend class for each of the items in teh z-indexs object
@mixin z-ex($map: $z-indexs) {
	$values: map-keys($map);
	@each $item in $values {
		@at-root {
			%#{$item} {
				z-index: map-get($map, $item);
// call it
@include z-ex();

// usage
// first argument is the named position, the named positions are set in the z-indexs object
// if you are creating a new position then you must provide some context for the position,
// this is where the above or below arguments come in.
// you must set which position the position should go above or below
// for example, my new position called slide needs to go above floor_1
// you can also pass in a tolerance, the default is 5.  This is the value that is added or subtracted 
// from the existing position
// Using extend will funnily enough create a silent placeholder than can be used again and again.
// if the new z-index value produced already exists in the object a new name will not be created 
// instead the existing on extended. keen!

// example
// .slide { @include z(slide, $above: floor_10); }
// .slide__pagination { @include z(slide_pagination, $above: slide)}

@mixin z($position: 1, $above: false, $below: false, $tolerance: 5, $extend: true) {

	$save_new_position: null;
	$results: null;
	$val: null;
	$new_map: null;
	$keys: null;
	$extended: null;

	// if the position already exists
	@if map-has-key($z-indexs, $position) {

		@debug 'key exists';
		// get the position value
		$result: map-get($z-indexs, $position);
		// if extend is true, 
		// extend the class created by z-ex
		@if $extend == true {
			@extend %#{$position};
		} @else {
			// or don't extend
			z-index: $result;

	// if the position does not yet exist
	@else {
		// set the direction, this is a little flaky
		$direction: null;
		@if $above != false {
			$direction: $above;

		@if $below != false {
			$direction: $below;

		@if $direction != null {
			// check to see if the direction exists, i.e a previously created position
			@if map-has-key($z-indexs, $direction) {
				// get the z-index value of the given position
				$val: map-get($z-indexs, $direction);
				// if its above need to add
				@if $direction == $above {
					$val: $val + $tolerance;
				// below minus
				@if $direction == $below {
					$val: $val - $tolerance;
				// update the map with the new position and value
				// this is a global variable
				$z-indexs: map-set($z-indexs, $position, $val) !global;
				// if we're extending
				@if $extend == true {

						// check to see if $val already exists
						// so assign each of the values to a var (list)
						$keys: map-values($z-indexs);
						// loop through each item in the list
						@each $value in $keys {
							// if the value matches the val, get the name of the key
							@if $val == $value {
								// get the index of the item
								$index: index($keys, $value);
								// return the resulting object
								$list: nth($z-indexs, $index);
								// the above returns both the key and the value, so now we just want the key
								// set this to the $extend var
								$extended: nth($list, 1);
						// so if floor_7 == 10 and new_position == 10, we don't need to create a new extend class
						@if $extended != $position {
							@extend %#{$extended};
						} @else {
							// it's a totally new position so let's create the extend.
							@at-root {
								%#{$position} {
									z-index: $val;
							// and now extend it.
							@extend %#{$position};
				} @else {
					// not extending, fair enough
					z-index: $val;

			} @else {
				@warn "above map position does not exist";

.a1 {
	@include z('floor_2');

.a2 {
	@include z('slide', $above: 'floor_2');

.a3 {
	@include z('slider', $above: 'slide');

.a4 {
	@include z('slide_item', $below: slider);

// output

.a1 {
  z-index: 50;
.a2, .a4 {
  z-index: 55;

.a3 {
  z-index: 60;