Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

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.

HTML

              
                <h1>3D CSS Ribbon</h1>

<p>A Sass/Compass plugin by <a href="http://dzign.us">Leandro D'Onofrio</a>.</p>
<p><a href="https://github.com/dzignus/compass-3d-ribbon">Instalation and intructions in Github.</a></p>

<h2>Examples</h2>

<p>This is a ribbon with the default styles:</p>

<!--Default ribbon -->
<h3 class="ribbon ribbon-default">Default ribbon</h3>

<p>There are a number of options to change the appearance of the ribbon like the colors, backgrounds and position of the ribbon's overlap:</p>

<!--Custom ribbon 1 -->
<h3 class="ribbon ribbon-custom-1">Ribbon with custom options</h3>

<p>For example, you can change the position of the ribbon's overlap to the top...</p>

<!--Custom ribbon 2 -->
<h3 class="ribbon ribbon-custom-2">← The overlap is on the top →</h3>

<p>or have only one overlap...</p>

<!--Custom ribbon 3 -->
<h3 class="ribbon ribbon-custom-3">← The overlap is on the left</h3>

<p>even create the overlap's back adding some span elements...</p>

<!--Custom ribbon 4 -->
<h3 class="ribbon ribbon-custom-4">
  ← The back's overlap on both sides →
  <span class="ribbon-left"></span>
  <span class="ribbon-right"></span>
</h3>

<p>and finally some fancy example:</p>

<!--Fancy example -->
<div class="fancy">
  <h2>
    <span class="ribbon-center">Bendin' <br> in the Wind</span>
    <span class="ribbon-left"></span>
    <span class="ribbon-right"></span>
  </h2>
  <p>The key to victory is discipline, and that means a well made bed. You will practice until you can make your bed in your sleep. So, how 'bout them Knicks? Incidentally, you have a dime up your nose.</p>
</div>
  
<p>PS: Shhh, they are responsive too! Try resize the window ;)</p>
              
            
!

CSS

              
                @import "compass/css3";

// 3D CSS Ribbon ------------------------------------------------------------
// Plugin by Leandro D'Onofrio - http://dzign.us/

//** Default variables for the ribbon **//

$ribbon-3d-background-color: #428bca!default;
$ribbon-3d-position: bottom!default;
$ribbon-3d-sides: left right!default;
$ribbon-3d-overlap-horizontal: 30px!default;
$ribbon-3d-overlap-vertical: 20px!default;
$ribbon-3d-overlap-color: darken($ribbon-3d-background-color, 30%)!default;

//** 3D CSS Ribbon mixin **//

@mixin ribbon(

    // Set the background color of the ribbon
    $background-color    : $ribbon-3d-background-color,
    
    // Set the position of the sides
    $position            : $ribbon-3d-position,

    // Set the sides of the ribbon
    $sides               : $ribbon-3d-sides,
    
    // Set the width of the overlaps
    $overlap-horizontal  : $ribbon-3d-overlap-horizontal,
    
    // Set the height of the overlaps
    $overlap-vertical    : $ribbon-3d-overlap-vertical,

    // Set the color of the edges
    $overlap-color       : $ribbon-3d-overlap-color

  ) {

    background-color: $background-color;
    position: relative;
    z-index: 6;

    &:before, &:after{
      content: "";
      width: 0; 
      height: 0;
      position: absolute;
      font-size: 0;
      line-height: 0;
      z-index: 5;

      @if $position == "bottom" {
        border-top: 0 solid transparent;
        border-bottom: $overlap-vertical solid transparent;
        bottom: -$overlap-vertical;
      }

      @if $position == "top" {
        border-bottom: 0 solid transparent;
        border-top: $overlap-vertical solid transparent;
        top: -$overlap-vertical;
      }

    }

    $sides-length: length($sides);

    @if ($sides == right) or ($sides-length == 2) {

      &:before{
        border-left: $overlap-horizontal solid $overlap-color;
        right: 0;
      }

    }

    @if ($sides == left) or ($sides-length == 2) {

      &:after{
        border-right: $overlap-horizontal solid $overlap-color;
        left: 0;
      }

    }

}

//** Default variables for the ribbon's back **//

$ribbon-3d-back-background-color: $ribbon-3d-background-color!default;
$ribbon-3d-back-position: $ribbon-3d-position!default;
$ribbon-3d-back-height: 40px!default;
$ribbon-3d-back-width: 60px!default;
$ribbon-3d-back-horizontal-distance: $ribbon-3d-overlap-horizontal!default;
$ribbon-3d-back-vertical-distance: $ribbon-3d-overlap-vertical!default;
$ribbon-3d-back-snip-color: transparent!default;

//** 3D CSS Ribbon mixin's back **//

@mixin ribbon-back(

    // The side to create
    $side,

    // Set the background color of the ribbon's back
    $background-color    : $ribbon-3d-back-background-color,

    // Set the position of the ribbon's back
    $position            : $ribbon-3d-back-position,

    // Set the height of the ribbon's back
    $height              : $ribbon-3d-back-height,

    // Set the width of the ribbon's back
    $width               : $ribbon-3d-back-width,

    // Set the vertical distance of the ribbon's back
    $horizontal-distance : $ribbon-3d-back-horizontal-distance,

    // Set the horizontal distance of the ribbon's back
    $vertical-distance   : $ribbon-3d-back-vertical-distance,

    // Set the color of the back's snip
    $snip-color          : $ribbon-3d-back-snip-color

  ){

  display: block;
  height: $height;
  width: $width;
  background-color: $background-color;
  position: absolute;
  z-index: -1;

  @if $side == left {
    left: - ($width - $horizontal-distance);
  }

  @if $side == right {
    right: - ($width - $horizontal-distance);
  }

  @if $position == bottom {
    bottom: -$vertical-distance;
  }

  @if $position == top {
    top: -$vertical-distance;
  }

  @if $snip-color != transparent {

    &:before{
      content: "";
      width: 0; 
      height: 0;
      position: absolute;
      font-size: 0;
      line-height: 0;
      border-bottom: $height / 2 solid transparent;
      border-top: $height / 2 solid transparent;

      @if $side == left {
        border-left: ($height / 2) / 2 solid $snip-color;
        left: 0;
      }

      @if $side == right {
        border-right: ($height / 2) / 2 solid $snip-color;
        right: 0;
      }

    }

  }

}

// End


//** Styles only for cosmetic purposes **//

body{
  font-family: "open sans", serif;
  width: 75%;
  margin: 0 auto;
  text-align:center;
  font-size: 16px;
  background-color: #FAFAFA;
  background-image: repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255,255,255,.5) 35px, rgba(255,255,255,.5) 70px);
}

p{
  margin: 5px 0;
}

.wrapper{
  width: 75%;
  margin: 0 auto;
  height: 100%;
}

.ribbon{
  padding: 5px;
  color: #FFF;
  text-transform: uppercase;
  text-align: center;
  font-family: 'Open Sans', sans-serif;
  font-weight: 100;
  margin-top: 0;
  margin-bottom: 60px;
}

//** Implementation **//

//Default
.ribbon-default{
  @include ribbon();
 }

//Custom 1
.ribbon-custom-1{
  @include ribbon(
    $background-color: #5cb85c,
    $position: bottom,
    $sides: left right,
    $overlap-horizontal: 20px,
    $overlap-vertical: 15px,
    $overlap-color: darken(#5cb85c, 15%) 
   );
 }

//Custom 2
.ribbon-custom-2{
  @include ribbon(
    $background-color: #5bc0de,
    $position: top,
    $sides: left right,
    $overlap-horizontal: 20px,
    $overlap-vertical: 15px,
    $overlap-color: darken(#5bc0de, 40%) 
   );
 }

//Custom 3
.ribbon-custom-3{
  @include ribbon(
    $background-color: #f0ad4e,
    $position: top,
    $sides: left,
    $overlap-horizontal: 20px,
    $overlap-vertical: 15px,
    $overlap-color: darken(#f0ad4e, 40%) 
   );
 }

//Custom 4
$ribbon-background-color: #d9534f;
$ribbon-position: top;
$ribbon-sides: left right;
$ribbon-overlap-horizontal-distance: 20px;
$ribbon-overlap-vertical-distance: 15px;
$ribbon-back-width: 20px;
$ribbon-back-height: 30px;

.ribbon-custom-4{
  @include ribbon(
    $background-color: $ribbon-background-color,
    $position: $ribbon-position,
    $sides: $ribbon-sides,
    $overlap-horizontal: $ribbon-overlap-horizontal-distance,
    $overlap-vertical: $ribbon-overlap-vertical-distance,
    $overlap-color: darken($ribbon-background-color, 30%) 
   );

  @each $side in $ribbon-sides {

    .ribbon-#{$side}{
      @include ribbon-back(
      $side: #{$side},
      $background-color: $ribbon-background-color,
      $position: $ribbon-position,
      $width: $ribbon-back-width,
      $height: $ribbon-back-height,
      $horizontal-distance: $ribbon-overlap-horizontal-distance,
      $vertical-distance: $ribbon-overlap-vertical-distance,
      $snip-color: transparent
      );
    }

  }
  
 }

//Fancy example
$ribbon-fancy-container-width: 300px;
$ribbon-fancy-container-padding: 15px;
$ribbon-fancy-background-color: #e54439;
$ribbon-fancy-position: bottom;
$ribbon-fancy-sides: left right;
$ribbon-fancy-overlap-horizontal-distance: 20px;
$ribbon-fancy-overlap-vertical-distance: 15px;
$ribbon-fancy-back-width: 60px;
$ribbon-fancy-back-height: 45px;

.fancy{
  width: $ribbon-fancy-container-width;
  margin: 0 auto 20px auto;
  background: #E7E7E7;
  padding: $ribbon-fancy-container-padding;
  border-radius: 15px;
  box-shadow: rgba(0, 0, 0, 0.5) 0px 0px 4px;
  
  h2{
    font-style: italyc;
    line-height: 1;
    padding: 5px 0;
    color: #FFF;
    margin: 0;
    text-shadow: rgba(0, 0, 255, 0.2) 1px 1px 0, rgba(0, 0, 255, 0.2) 2px 2px 0, rgba(0, 0, 255, 0.2) 3px 3px 0;
    width: $ribbon-fancy-container-width + ($ribbon-fancy-overlap-horizontal-distance * 2) + ($ribbon-fancy-container-padding * 2);
    left: -($ribbon-fancy-overlap-horizontal-distance + $ribbon-fancy-container-padding);

    @include ribbon(
      $background-color: $ribbon-fancy-background-color,
      $position: $ribbon-fancy-position,
      $sides: $ribbon-fancy-sides,
      $overlap-horizontal: $ribbon-fancy-overlap-horizontal-distance,
      $overlap-vertical: $ribbon-fancy-overlap-vertical-distance,
      $overlap-color: lighten($ribbon-fancy-background-color, 30%) 
     );
    
    .ribbon-center{
      display: block;
      background-color: $ribbon-fancy-background-color;
      box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    }

    @each $side in $ribbon-fancy-sides {

      .ribbon-#{$side}{
        @include ribbon-back(
        $side: #{$side},
        $background-color: $ribbon-fancy-background-color,
        $position: $ribbon-fancy-position,
        $width: $ribbon-fancy-back-width,
        $height: $ribbon-fancy-back-height,
        $horizontal-distance: $ribbon-fancy-overlap-horizontal-distance,
        $vertical-distance: $ribbon-fancy-overlap-vertical-distance,
        $snip-color: #FFF
        );
      }

    }

  }
  
  p{
    line-height: 1.5;
  }

}
              
            
!

JS

              
                
              
            
!
999px

Console