I am trying to achieve the following by putting two divs side by side to each other.
What I tried is, rotating the second div as well as tried to use a linear-gradient
but it doesn’t give me the same result.
This was the closet I was able to get to it, but I need the divs to be side by side, and not inside it.
<div style="width: 100vh; height:20vh; position: relative; background-color: black;">
<div style="background: linear-gradient(to bottom right, transparent 50%, red 50%); width: 50%; height:100%; position: absolute; top: 0; right: 0;"></div>
</div>
2
Answers
I was able to achieve the desired result using a polygon.
Why don’t you create 2 elements for both colours, then wrap them in a parent element and rotate parent via
transform: rotate(90deg);
?Obviously adjust the angle to fit your needs and give
border-radius
.This parent then could be positioned using absolute / relative – depending on the layout…