cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmloctocatspinnerstartv

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.

            
              <h1>material-shadow.scss</h1> 
<p>A mixin based on Material Design box shadows with 5 presets and a strength setting.</p>

<p>sample usage:</p>
<code>@include material-shadow($z-depth: 3);</code>
<code>@include material-shadow(3);</code>
<section>
  <div>$z-depth: 1</div>
  <div>$z-depth: 2</div>
  <div>$z-depth: 3</div>
  <div>$z-depth: 4</div> 
  <div>$z-depth: 5</div>    
</section>

<h3>Increase strength for darker backgrounds</h3>  

<p>sample usage:</p>
<code>@include material-shadow($z-depth: 3, $strenght: 2);</code>
<br/><br/>
<section class="dark">
  <div>$z-depth: 1, $strength: 2</div>
  <div>$z-depth: 2, $strength: 2</div>
  <div>$z-depth: 3, $strength: 2</div>
  <div>$z-depth: 4, $strength: 2</div>  
  <div>$z-depth: 5, $strength: 2</div>   
</section>

<h3>sample hover</h3>
<section>
  <div class="float">hover us</div>
  <div class="float">hover us</div>  
</section>
            
          
!
            
              //- Mixin: Material Shadow
///
/// Box shadows based on 5 Material Design presets;
///
/// @param {variable} $z-depth [1] - shadow distance on z-axis
/// @param {variable} $strength [1] - multiplier for shadow strength/darkness
/// @param {variable} $color [1] - shadow color
/// @group layout
/// @example
///   div {
///     @include material-shadow(3);
///   }
/// @link http://codepen.io/dbox/pen/RawBEW

@mixin material-shadow($z-depth: 1, $strength: 1, $color: black) {
  @if $z-depth == 1 {
    box-shadow: 0 1px 3px rgba($color, $strength * 0.14), 0 1px 2px rgba($color, $strength * 0.24);
  }
  @if $z-depth == 2 {
    box-shadow: 0 3px 6px rgba($color, $strength * 0.16), 0 3px 6px rgba($color, $strength * 0.23);
  }  
  @if $z-depth == 3 {
    box-shadow: 0 10px 20px rgba($color, $strength * 0.19), 0 6px 6px rgba($color, $strength * 0.23);
  }    
  @if $z-depth == 4 {
    box-shadow: 0 15px 30px rgba($color, $strength * 0.25), 0 10px 10px rgba($color, $strength * 0.22);    
  }
  @if $z-depth == 5{
    box-shadow: 0 20px 40px rgba($color, $strength * 0.30), 0 15px 12px rgba($color, $strength * 0.22);   
  }
  @if ($z-depth < 1) or ($z-depth > 5) {
    @warn "$z-depth must be between 1 and 5";
  }
}

// call it
div {  
  @for $i from 1 through 5 {
    &:nth-child(#{$i}) {
      @include material-shadow($z-depth: $i);
    }
  }  
}

.dark div {
  @for $i from 1 through 5 {
    &:nth-child(#{$i}) {
      @include material-shadow($z-depth: $i, $strength: 2);
    }
  }  
}

.float {
  transition: all .2s ease-out;
  &:hover {
    transform: translateY(-5px);
    @include material-shadow(5);
  }
}

// ignore me

section {
  padding: 40px;
  display:flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  align-items: center;
  margin: 20px;
  background: #f3f3f3; 
}

div {
  font-size: 12px;
  background: #fff;
  padding: 50px;
  text-align: center;
  flex-basis: 100px;
  margin: 15px;  
}
.dark {
  background: #555;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Open Sans", "Helvetica Neue", Arial, sans-serif;
  padding: 0 5%;
}
code {
  background: #f3f3f3;
  padding: 5px 12px;
  color: #ff3333;
  border: 1px solid #ddd;
}

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console