Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding border to CSS triangle [duplicate]

Tags:

I have a triangle

<div class="triangle-left"></div>   .triangle-left {     width: 0;      height: 0;      border-top: 22px solid transparent;     border-bottom: 22px solid transparent;     border-right: 22px solid white; } 

How do I draw the outline of a CSS triangle, considering border itself is used to make the triangle? External divs?

like image 665
propster Avatar asked Mar 12 '15 03:03

propster


1 Answers

One way to do it is the create an inner triangle which is smaller.

.triangle-left {      width: 0;      height: 0;      border-top: 23px solid transparent;      border-bottom: 23px solid transparent;      border-right: 23px solid red;  }    .inner-triangle {      position: relative;      top: -20px;      left: 2px;      width: 0;      height: 0;      border-top: 20px solid transparent;      border-bottom: 20px solid transparent;      border-right: 20px solid blue;  }
<div class="triangle-left">      <div class="inner-triangle"></div>  </div>
like image 111
RSquared Avatar answered Jan 03 '23 11:01

RSquared