CSS Ribbon

Ribbon-like headers are graphic element that have in the past customarily required images. With CSS, we can now create a ribbon with some border and pseudo-element tricks.

In this article we will describe the steps required to obtain the following result :

ribbon_css

The first step is the main element. In the following example we will use 70 % of the total width.

css-ribbon-step1


.ribbon {
    font-size : 16px !important;
    width : 20%;
    position: relative;
    background: #757449;
    color: #fff;
    text-align: center;
    padding: 1em 2em;
    margin: 2em auto 3em;
}

In the second step we will define the ribbon extremity using the before and after pseudo elements:

css-ribbon-step2

.ribbon:before, .ribbon:after {
    content: "";
    position: absolute;
    display: block;
    bottom: -1em;
    border: 1.5em solid #757449;
    z-index: -1;
}
.ribbon:before {
     left: -2em;
     border-right-width: 1.5em;
     border-left-color: transparent;
}
.ribbon:after {
     right: -2em;
     border-left-width: 1.5em;
     border-right-color: transparent;
}

The third and last step is giving the ribbon fold the third dimension with a triangle shadow using the same technic as the second step.

css-ribbon-step3

.ribbon .ribbon-fold:before, .ribbon .ribbon-fold:after {
     content: "";
     position: absolute;
     display: block;
     border-style: solid;
 
 
     border-color: #4B490B transparent transparent transparent;
     bottom: -1em;
}
.ribbon .ribbon-fold:before {
    left: 0;
    border-width: 1em 0 0 1em;
}
.ribbon .ribbon-fold:after {
    right: 0;
    border-width: 1em 1em 0 0;
}

Ribbon Generator

The following link propose you a ribbon generator to create your Ribbon CSS according to the look and feel or your Website

http://app.java-tutorial.ch/css-tools/public/css-ribbon-builder.jsf

If you have any remark or questions feel free to put a comment.If you enjoyed this tutorial and want to promote it don't hesitate to click on

Tags: describe , http , create , required , website , ribbon , generator , obtain , //www.1privata.com/css-tools/public/css-ribbon-builder.jsf