It's because all you're seeing is the bottom-border-color
. The left and right borders are transparent, and the top border has no width at all (border-top-width:0;
).
Element borders meet at an angle calculated based on the widths of the two borders. So if the borders are both the same width, the angle is 45 degrees. Unequal border widths will create other angles.
Because the .triangle
element has no width or height, those angles converge at a single point. The code below will help demonstrate the concept:
.borders {
border-bottom-color: green;
border-left-color: red;
border-right-color: blue;
border-top-color: pink;
border-style: solid;
border-width: 50px;
height: 50px;
width: 50px;
}
.triangles {
border-bottom-color: green;
border-left-color: red;
border-right-color: blue;
border-top-color: pink;
border-style: solid;
border-width: 50px;
height: 0;
width: 0;
}
.triangle {
border-color: transparent;
border-bottom-color: green;
border-style: solid;
border-width: 50px;
height: 0;
width: 0;
}
<div class="borders"></div>
<hr>
<div class="triangles"></div>
<hr>
<div class="triangle"></div>