cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-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="wrapper">
  <h2>Image, no options</h2>
  <!-- default -->
  <div class="default">
    <div class="svg basic"></div>
    <p class="caption">default</p>
  </div>
  <!-- IE -->
  <div class="ie8">
    <div class="svg basic"></div>
    <p class="caption">IE 8</p>
  </div>
  <!-- No SVG -->
  <div class="no-svg">
    <div class="svg basic"></div>
    <p class="caption">No SVG</p>
  </div>
</div>
<div class="wrapper">
  <h2>Set background size</h2>
  <!-- default -->
  <div class="default">
    <div class="svg awesome"></div>
    <p class="caption">default</p>
  </div>
  <!-- IE -->
  <div class="ie8">
    <div class="svg awesome"></div>
    <p class="caption">IE 8</p>
  </div>
  <!-- No SVG -->
  <div class="no-svg">
    <div class="svg awesome"></div>
    <p class="caption">No SVG</p>
  </div>
</div>
<div class="wrapper">
  <h2>Background cover</h2>
  <!-- default -->
  <div class="default">
    <div class="svg moreawesome"></div>
    <p class="caption">default</p>
  </div>
  <!-- IE -->
  <div class="ie8">
    <div class="svg moreawesome"></div>
    <p class="caption">IE 8</p>
  </div>
  <!-- No SVG -->
  <div class="no-svg">
    <div class="svg moreawesome"></div>
    <p class="caption">No SVG</p>
  </div>
</div>
            
          
!
            
              
//
// SVG Background
// -------
//
// FOR: Setting PNG fallbacks for SVG background images
//
// 1. Need to set a default image path (ex: ../img/)
// 2. This uses multiple background images as a proxy for SVG support
// 3. Necessary override for some versions of
//    Android, which choke on the double bg image
// 4. Background images need to be pre-sized for IE 8
//
// NOTE: You still need to set the display (inline-block or block)
//       and a height/width for the container
//
// REF: https://css-tricks.com/svg-fallbacks/
// USE: @include svg(envelope, 50% 50%);

@mixin svg(
    $bg-name: false,
    $bg-position: 50% 50%,
    $bg-color: transparent,
    $bg-size: 100%
  ) {

  // Variables
  //$svg-path [1]
  $svg: $svg-path + $bg-name + ".svg";
  $png: $svg-path + $bg-name + ".png";
  $png-ie: $svg-path + $bg-name + "-ie.png";

  background-image: url("#{$png}");
  background-image: url("#{$svg}"), none; // [2]

  // Other background properties
  background-color: $bg-color;
  background-repeat: no-repeat;
  background-position: $bg-position;
  background-size: $bg-size;

  .no-svg & {
    background-image: url("#{$png}"); // [3]
  }

  .ie8 & {
    background-image: url("#{$png-ie}"); // [4]
  }

} // svg

// -------

// Define a global variable for image directory
$svg-path: "http://www.thetrace.org/wp-content/themes/thetrace/static/img/icons/";

// Base Styles
// -------

* {
  box-sizing: border-box;
}
body {
  font-family: sans-serif;
}
.wrapper {
  width: 240px;
  margin: 0 auto 20px;
}
.wrapper > div {
  float: left;
  margin-right: 15px;
}
h2 {
  font-size: 18px;
}
.caption {
  text-align: center;
  color: #999;
  font-size: 12px;
}
.svg {
  display: block;
  width: 60px;
  height: 60px;
}

// Add your SVGs
// -------

.basic {
  @include svg(envelope);
}

.awesome {
  @include svg(envelope, 50% 50%, #bada55, 30px auto);
}

.moreawesome {
  @include svg(envelope, 50% 50%, #bada55, cover);
}

            
          
!
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