How to create a ribbon shape in CSS

前端 未结 8 886
旧时难觅i
旧时难觅i 2021-01-05 15:00

http://jsfiddle.net/6HyjZ/

.bookmarkRibbon{
     width:0; 
     height:100px; 
     border-right:50px solid blue;
     border-left:50px solid blue;
     bord         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 15:22

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

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

提交回复
热议问题