How Create a HTML/CSS Ribbon. Simple and Light (None Jpg/Png Image)

Here’s a simple html/css line that could generate a ribbon background with text.

DEMO: CSS Ribbon for Your Website

My Ribbon

HTML

Copy the code below and paste into your HTML document.

<div class="ribbon">
    <span class="ribbon-text">My Ribbon</span>
</div>

CSS

Copy the code below and paste into your CSS document.

.ribbon {
    position: relative;
    background: blue;
    text-align: center;
    z-index: 1;
    width: 240px;
    height: 52px;
    margin: 0 auto;
}
.ribbon-text {
    position: relative;
    display: block;
    font-size: 2em;
    color: white;
 }
.ribbon:before {
    content: '';
    border: 26px solid blue;
    border-left-color: transparent;
    border-left-width: 14px;
    position: absolute;
    top: 0;
    left: -20px;
}
.ribbon:after {
    content: '';
    border: 26px solid blue;
    border-right-color: transparent;
    border-right-width: 21px;
    position: absolute;
    top: 0;
    right: -27px;
}

You can tweak around with different colors and size of the ribbon. Have fun!

Leave a Reply

Your email address will not be published. Required fields are marked *