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?

8 Answers 8

32

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>

Sign up to request clarification or add additional context in comments.

2 Comments

Not only is this the best answer of this question, this is the best answer I've ever seen on this forum in general
very well explained! TY!
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>

Comments

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

Comments

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/

Comments

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 */
}

Comments

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;
}

Comments

-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)

1 Comment

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)
-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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.