Triangle with white border

How can I create a triangle with a white border using CSS? Like the image below.

enter image description here

when i add this css

.triangle {
    width:0;
    height:0;
    border-top: 20px solid transparent; 
    border-left: 20px solid white; 
    border-bottom: 20px solid transparent;
    position:relative;

}
.triangle:before {
    content:'';
    width:0;
    height:0;
    border-top: 10px solid transparent; 
    border-left: 10px solid red; 
    border-bottom: 10px solid transparent;
    position:absolute;
    top:-10px;
    left:-17px;
}

      

result

enter image description here

+3


source to share


1 answer


CSS

.triangle {
    width:0;
    height:0;
    border-top: 20px solid transparent; 
    border-left: 20px solid white; 
    border-bottom: 20px solid transparent;
    position:relative;

}
.triangle:before {
    content:'';
    width:0;
    height:0;
    border-top: 10px solid transparent; 
    border-left: 10px solid red; 
    border-bottom: 10px solid transparent;
    position:absolute;
    top:-10px;
    left:-17px;
}

      

HTML:



<div class="triangle"></div>

      

Fiddle

+1


source







All Articles