How to create a triangle with border only on one side of the triangle using only html and css. How would I be able to achieve that.
I am able to create a triangle using different methods like clip-path, linear gradient but the border is something which is very tricky
2
line { stroke-linecap: round; } .stroked { stroke: magenta; stroke-width: 1; } :not(.stroked) { stroke: teal; stroke-width: 0.25; }
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <line x1="20" y1="50" x2="50" y2="10"></line> <line x1="50" y1="10" x2="80" y2="50"></line> <line class="stroked" x1="80" y1="50" x2="20" y2="50"></line> </svg>
clip-path combined with gradient
.box { height: 300px; clip-path: polygon(100% 0, 100% 100%, 0 100%); /* 10px = thickness */ background: linear-gradient(to bottom right, red calc(50% + 10px), lightblue 0); } body { margin: 0; }
<div class="box"></div>
Click here to cancel reply.
2
Answers
clip-path combined with gradient