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

Auto Save

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='container lead'>
  <h1>Isolating Box Shadows</h1>	
  <h2>A Simple & Often Misunderstood CSS Fundamental</h2>
  <p>To isolate a single shadow we apply a negative spread and offset in the desired direction, then add a blur radius of equal distance to compensate. For inset shadows, the spread remains constant but we apply an offset in the opposite (-ve) direction. For multiple sides/shadows, simply combine any of the desired single-side rules into a comma separated list.</p>
</div>

<div class='container'>
  <div class="box top"></div>
  <div class="box right"></div>
  <div class="box bottom"></div>
  <div class="box left"></div>
  <div class="box all"></div>
</div>

<div class='container'>
  <div class="box inset-top"></div>
  <div class="box inset-right"></div>
  <div class="box inset-bottom"></div>
  <div class="box inset-left"></div>
  <div class="box inset-all"></div>
</div>

<div class='container'>
  <div class="box top-bottom"></div>
  <div class="box left-right"></div>
  <div class="box inset-top-bottom"></div>
  <div class="box inset-left-right"></div>
</div>
              
            
!

CSS

              
                $w: 15px; // shadow size
$color: #2C3E50;
$box_w: 4 * 40px;
$box_h: 3 * 40px;
$box-color: #16A085;
$label-color: #fff;
$bgcolor: #1ABC9C;
$text-color: #fff;



//--------------------------------------------------------------------
// Here's the important stuff, 
// Click the 'view compiled' button if you don't know SASS/SCSS
//--------------------------------------------------------------------


/*  CSS Spec:  | style | offset-x | offset-y | blur-radius | spread-radius | color */
$shadows: (               
	top          :            0          (-$w)       $w            (-$w)       $color,
  right        :            $w         0           $w            (-$w)       $color,
  bottom       :            0          $w          $w            (-$w)       $color,
  left         :            (-$w)      0           $w            (-$w)       $color,
  all          :            0          0           $w                        $color,
  inset-top    : inset      0          $w          $w            (-$w)       $color,
  inset-right  : inset      (-$w)      0           $w            (-$w)       $color,
  inset-bottom : inset      0          (-$w)       $w            (-$w)       $color,
  inset-left   : inset      $w         0           $w            (-$w)       $color,
  inset-all    : inset      0          0           $w                        $color,

  /* You may also combine and comma separate any shadows from above */
  left-right       : (       (-$w) 0     $w (-$w) $color,       $w    0     $w (-$w) $color),
  top-bottom       : (       0     (-$w) $w (-$w) $color,       0     $w    $w (-$w) $color),
  inset-left-right : (inset  $w    0     $w (-$w) $color, inset (-$w) 0     $w (-$w) $color),
  inset-top-bottom : (inset  0     $w    $w (-$w) $color, inset 0     (-$w) $w (-$w) $color),
);
  
// Loop and create style
@each $k, $v in $shadows {
  .#{$k} {box-shadow:$v;}
}


//--------------------------------------------------------------------
// Ignore me I'm just eye candy
//--------------------------------------------------------------------
@import url(https://fonts.googleapis.com/css?family=Slabo+27px);

body {
  background-color: $bgcolor ;
  color:$text-color;
  letter-spacing: 1px;
  font: 1em 'Slabo 27px', serif;
  
  h1 { margin:20px; font-size:3.5em; letter-spacing:5px; color: #006666; text-align:center; font-weight:bold;}
  h2 { margin:20px; font-size:1.5em; color: #006666; text-align:center;}
  p  { margin:20px; font-size:1.1em; }
  .container {
    text-align:center;
    clear:both;
    margin:auto;
    max-width: 6 * $box_w;
    &.lead {
      max-width:710px;
      text-align:justify;
    }
  }
  
  .box {
    display:inline-block;
    height: $box_h;
    width: $box_w;
    margin: 30px 10px;
    position:relative;
    background: $box-color;

    &:after {
      color:$label-color;
      position:absolute;
      top:0;
      left:0;
      right:0;
      bottom:0;
      line-height: $box_h;
      color:#eee;
      content: attr(class) " ";
    }
  }
}



              
            
!

JS

              
                
              
            
!
999px

Console