8

http://jsfiddle.net/6HyjZ/

.bookmarkRibbon{
     width:0; 
     height:100px; 
     border-right:50px solid blue;
     border-left:50px solid blue;
     border-bottom:30px solid transparent;
}

<div class="bookmarkRibbon"></div>

I'm struggling to make a version of this shape where the ribbon is pointing right instead of down, how can I achieve this?

web-tiki
  • 99,765
  • 32
  • 217
  • 249
user3531149
  • 1,519
  • 3
  • 30
  • 48

8 Answers8

31

Ribbon shape using CSS Clip Path:

.bookmarkRibbon {
  width: 100px;
  height: 60px;
  background: blue;
  clip-path: polygon(0% 0%, 100% 0%, calc(100% - 20px) 50%, 100% 100%, 0% 100%);
}
<div class="bookmarkRibbon"></div>

Pointing down:

.bookmarkRibbon {
  width: 60px;
  height: 100px;
  background: blue;
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% calc(100% - 20px), 0% 100%, 0% 0%);
}
<div class="bookmarkRibbon"></div>

Ribbon shape using CSS border

To help you visualize the logic step-by-step, so you can apply it easily on any side:

CSS Ribbon Shape - How To Create

.bookmarkRibbon {
  border:       30px solid blue;        /* All borders set */
  border-left:  0;                      /* Remove left border */
  border-right: 20px solid transparent; /* Right transparent */
  width:        100px;                  /* Increase element Width */
}
<div class="bookmarkRibbon"></div>
Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
4

Using the helpful accepted answer here is it with text version.

Vertical(Top to bottom) Banner with text

.ribbon-vertical {
 position: absolute;
 right: 10px;
   border:       13px solid #e46a76;        /* All borders set */
   border-top:  0;                      /* Remove left border */
   border-bottom: 10px solid transparent; /* Right transparent */
   height: auto;                  /* Increase element Width */
   width: 0;
   word-wrap: break-word;
   color: white;
   z-index: 1;
   -webkit-filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
      filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.ribbon-vertical div{
    position: relative;
    right: 5px;
    padding-top: 2px;
    padding-bottom: 2px;
}
<div class="ribbon-vertical"><div>BANNER</div></div>

Horizontal(Right to Left) Banner with text

.ribbon-horizontal{
 position: absolute;
 right: 0;
 bottom: 5rem;
   border: 13px solid #e46a76;
   border-right: 0;
   border-left: 10px solid transparent;
   height: 0;
   line-height: 0;
   width: 100px;
   color: white;
   z-index: 1;
   -webkit-filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
      filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
 letter-spacing: 3px;
}
.ribbon-horizontal span{
 position: relative;
 padding: 0 4px 0 10px;
 text-align: center;      
}
<div class="ribbon-horizontal"><span>BANNER</span></div>
MR_AMDEV
  • 1,712
  • 2
  • 21
  • 38
0
.bookmarkRibbon{
     width:100px; 
     height:0; 
     border-bottom:50px solid blue;
     border-top:50px solid blue;
     border-right:30px solid transparent;
}
Geoffrey Burdett
  • 1,906
  • 1
  • 14
  • 26
0

If you 'rotate' the css properties, it rotates the form by 90 degrees.

.bookmarkRibbon{
     width:100px; 
     height:0; 
     border-bottom:50px solid blue;
     border-top:50px solid blue;
     border-left:30px solid transparent;
}

http://jsfiddle.net/6HyjZ/6/

Math
  • 2,399
  • 2
  • 20
  • 22
0

Use transform:rotate :

.bookmarkRibbon{
     width:0; 
     height:100px; 
     border-right:50px solid blue;
     border-left:50px solid blue;
     border-bottom:30px solid transparent;
    transform:rotate(7deg);
    -ms-transform:rotate(7deg); /* IE 9 */
    -webkit-transform:rotate(7deg); /* Opera, Chrome, and Safari */
}
Niezborala
  • 1,857
  • 1
  • 18
  • 27
0

Just swap what you have and you are good to go jsfiddle:

.bookmarkRibbonRight{
     width:100px; 
     height:0px; 
     border-right:30px solid transparent;
     border-bottom:50px solid blue;
     border-top:50px solid blue;
}
Borys Generalov
  • 2,255
  • 17
  • 19
-1

You already have the shape, just use the transform property to change its angle.

Here is the code that I have added to the code you have.

 transform: rotate(270deg);

Here is the fiddle, http://jsfiddle.net/6HyjZ/11/ It now points to the right (unless that's right right side)

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103
  • he's just *struggling to make a version of this shape where the ribbon is pointing right instead of down* so it's achievable in pure CSS2 (IE8 friendly) – Roko C. Buljan Jun 13 '14 at 14:18
-2

Use the rotate css transform:

 .bookmarkRibbon{
      width:0; 
      height:100px; 
      border-right:50px solid blue;
      border-left:50px solid blue;
      border-bottom:30px solid transparent;
     -webkit-transform: rotate(90deg);
     -ms-transform: rotate(90deg);
     transform: rotate(90deg);
 }

http://jsfiddle.net/6HyjZ/13/

LcSalazar
  • 16,524
  • 3
  • 37
  • 69