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="one">
  level one
  <div class="two">
    level two
    <div class="three">
      level three
      <div class="level-up">
        Go one level up
      <div class="inception">
        Context from three levels deep.

              @import "compass/css3";

// simple function to find the context of a nested percentage.
@function nested-context($contexts) {
  // First level deep is always 100%
  $percentage: 100%;
  // Loop through each level
  @each $context in $contexts {
    // Invert the percentage to find context
    $percentage: percentage($percentage / $context);
  // Return final percentage
  @return $percentage;

// mixin to make things easier
@mixin nested-context($contexts, $position: left) {
  width: nested-context($contexts);
  @if $position == "center" {
    position: relative;
    left: 50%;
    margin-left: nested-context($contexts) * -.5;
  @if $position == "right" {
    margin-left: nested-context($contexts) * -1 + 100%;

// Find the context of percentage widths from deeply nested containers.

.level-up {
  @include nested-context(28%);
  background: blue;

.inception {
  // list as many levels deep as you want
  width: nested-context(28% 63% 84%);
  background: red;

.one   { width: 84%; }
.two   { width: 63%; }
.three { width: 28%; }

.one, .two, .three {
  height: 100%;
  background: rgba(#FF9900, .2);

html, body {
  height: 100%;
Loading ..................