Creating responsive triangles with CSS
I was trying to create triangles in CSS for a responsive site today and couldn't find a good example on stackoverflow, so here's how I did it. Making angular shapes responsive is a little tricky because you can't use percentages as border values in your CSS, so I wrote a couple functions to calculate the page width and resize a triangle accordingly. The first calculates the size on loading the page, the second recalculates the size as the page width changes. CSS: .triangle { width: 0; height: 0; border-top: 50px solid rgba(255, 255, 0, 1); border-right: 100px solid transparent; } HTML: <div