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

              
                <h1>Wrap-around ribbons with Sass</h1>
<hr />
<div class="wrapper">
    <div class="basic">
        <div class="container b1">Left ribbon</div>
        <div class="container b2">Right ribbon</div>
        <div class="container b3">Both ribbons</div>
    </div>
    <div class="implemented ">
        <div class="demo simple">
            <h2>Wrap-Around Ribbons</h2>
            <div class="box">
                <p>Basic Example</p>
            </div>
        </div>
        <div class="demo fancy">
            <h2>Wrap-around Ribbons</h2>
            <div class="box">
                <p>Fancy Example</p>
            </div>
        </div>
    </div>
</div>
<hr />
<p>Created by <a href="http://ricardozea.design/?=codepen" target="_blank" title="Link opens in a new tab">Ricardo Zea</a></p>
              
            
!

CSS

              
                //Put this whole mixin in your .scss file:
@mixin ribbon( $ribbon-color:black, $size-left:1em, $size-right:1em) {
    position: relative;
    &:before,
    &:after {
        content: "";
        position: absolute;
    }
    &:before {
        border-top: $size-left solid $ribbon-color;
        bottom: -$size-left;
        border-left: $size-left solid transparent;
        left: 0;
    }
    &:after {
        border-top: $size-right solid $ribbon-color;
        bottom: -$size-right;
        border-right: $size-right solid transparent;
        right: 0;
    }
}


/*Usage:
.selector { @include ribbon($y, 1em, 0); }

Explanation of mixin values:
A. $y: Is the color, I used a Sass variable but you can use whatever you want: #f00 - red - #ff0000
B. 1em: Is the dimensions of the ribbon(s)
C. "1em, 0": Means you're only doing the ribbon on the left
D. "0, 1em": Means you're only doing the ribbon on the right
E. "1em, 1em": Means you're  doing both ribbons  on left and right
*/

//This is the container to which you're going to apply the ribbon to
.container {
    display: inline;
    margin: 0 2%;
    padding: 40px 20px;
    background: $b;
}

//These are the ribbons themselves:

//Left ribbon
.b1 { @include ribbon($y, 1em, 0); }

//Right ribbon
.b2 { @include ribbon($y, 0, 1em); }

//Both ribbons
.b3 { @include ribbon($y, 1em, 1em); }


/*=========*/

//Demos on the right side with red headers
.demo {
    margin-bottom: 20px;
    &:last-of-type {
        margin: 0;
    }
}

//The red headings use the ribbons, see @include property below
h2 {
    @include ribbon(darken($r, 30%), 15px, 15px);
    width: 300px;
    margin: auto;
    padding: 2%;
    background: $r;
}

//Blue boxes under the header
.box {
    width: 270px;
    margin: auto;
    padding: 4%;
    clear: both;
    background: $g;
    box-shadow: inset 0 3px 0 rgba(black, .2);
    font-weight: bold;
}

//Gradient box, fancier-looking demo
.fancy {
    text-shadow: 0 -1px 0 rgba(black, 1);
    h2 {
        background-image: linear-gradient($r, darken($r, 20%));
        box-shadow: 0 2px 2px 1px rgba(black, .2);
    }
    .box {
        border-radius: 0 0 5px 5px;
        background-image: linear-gradient(darken($b, 25%), darken($b, 30%));
        box-shadow: 0 2px 4px 1px rgba(black, .2);
    }
}

//***********NOT NEEDED FOR DEMO***********
.wrapper {
    display: flex;
    & > div {
        padding: 20px 20px 30px;
        margin: 10px;
        background: rgba(white, .05);
        display: inline-block;
        width: 100%;
        border: rgba(white, .06) 1px solid;
        border-radius: 2px;
        box-shadow: 0 2px 2px rgba(black, .1);
    }
}

.basic {
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    width: auto;
}

.new-window {
    position: relative;
    padding-right: 16px;
    &:after {
        content: '';
        display: block;
        width: 14px;
        height: 12px;
        position: absolute;
        top: 10%;
        right: 0;
        background: url(https://i.stack.imgur.com/3H2PQ.png) no-repeat;
    }
}
              
            
!

JS

              
                /*
Original Article:
http://asgeirhoem.no/ex/css-wraparound-ribbon/

Inspired by this article:
http://www.kendallsdesign.com/blog/sass-mixin-wrap-around-ribbons

*/

//Add a title to the links that open in a new tab/window
$("a[target='_blank']").attr({title:'Opens in a new tab/window'}).addClass('new-window');

              
            
!
999px

Console