#triangles {
width: 100px;
height: 100px;
display: inline-block;
}
#triangles div {
height: 100%;
}
.tr-left {
background:
linear-gradient(to top left, transparent 50%, red 0) 0 100%/50% 50% no-repeat,
linear-gradient(to bottom left, transparent 50%, red 0) 0 0/50% 50% no-repeat;
}
.tr-right {
background:
linear-gradient(to top right, transparent 50%, yellow 0) 100% 100%/50% 50% no-repeat,
linear-gradient(to bottom right, transparent 50%, yellow 0) 100% 0/50% 50% no-repeat;
}
.tr-top {
background:
linear-gradient(to top right, transparent 50%, green 0) 0 0/50% 50% no-repeat,
linear-gradient(to top left, transparent 50%, green 0) 100% 0/50% 50% no-repeat;
}
.tr-bottom {
background:
linear-gradient(to bottom right, transparent 50%, blue 0) 0 100%/50% 50% no-repeat,
linear-gradient(to bottom left, transparent 50%, blue 0) 100% 100%/50% 50% no-repeat;
}
<div id="triangles" class="tr-left"></div>
<div id="triangles" class="tr-left">
<div class="tr-right"></div>
</div>
<div id="triangles" class="tr-top">
<div class="tr-right"></div>
</div>
<div id="triangles" class="tr-left">
<div class="tr-bottom">
<div class="tr-top">
<div class="tr-right"></div>
</div>
</div>
</div>