How to create a ribbon shape in CSS

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 create a version of this form where the tape points straight and not down, how can I achieve this?

+2
source share
9 answers

To help you visualize logic step by step
so you can easily apply it to ANY SIDE you want:

CSS Ribbon Shape - How To Create

.bookmarkRibbon {
  border:       50px solid blue;        /* All borders set */
  border-left:  0;                      /* Remove left border */
  border-right: 30px solid transparent; /* Right transparent */
  width:        100px;                  /* Increase element Width */
}
<div class="bookmarkRibbon"></div>
Run codeHide result
+12
source
.bookmarkRibbon{
     width:100px; 
     height:0; 
     border-bottom:50px solid blue;
     border-top:50px solid blue;
     border-right:30px solid transparent;
}
0
source

css, 90 .

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

0

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

, , jsfiddle:

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

, .

( )

.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>
Hide result

( )

.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>
Hide result

0

:

 transform:rotate(90deg);
-ms-transform:rotate(90deg); /* IE 9 */
-webkit-transform:rotate(90deg); /* Opera, Chrome, and Safari */

-1

, transform, .

, , .

 transform: rotate(270deg);

, http://jsfiddle.net/6HyjZ/11/ ( )

-1

rotate css:

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

-2

All Articles