It can be. There has been some talk about triangles/shapes in CSS lately (at least 1 or 2 posts in the past week).
My post started with something I wrote on Twitter that got me roasted yesterday, mainly for making an absolute statement that people didn't agree with, so I wanted to add a longer explanation:
These are great options, and they would simplify considerably the background-image method. I had conic-gradient aside because Firefox didn't support it (not to mention IE). But that has changed now in FF, and this is a great use of it.
Thank you for the article!
Using CSS borders, you can create any triangles of different angles (but not more than 90). It is not at all necessary to divide by 2 and be limited to only this. jsfiddle.net/m0zwLdju/
You are correct, that's not the only way to draw a triangle using the borders. I updated the article to add a note indicating that those are the steps for that specific triangle and other triangles will be slightly different:
Note: The steps above are for a specific triangle. The actual steps will change (slightly) depending on the type of triangle that we want to draw. In general, the idea is to set 2-3 borders as transparent and 1-2 borders with color and then adjust the border sizes.
I'm Calin Baenen – AKA KattyTheEnby – a programmer born October 30th, 2006.
I love programming, it has been my passion since I was a kid, and will forever be my passion.
Coincidence --> dev.to/dailydevtips1/css-shapes-tr...
Same topic, same day!
It can be. There has been some talk about triangles/shapes in CSS lately (at least 1 or 2 posts in the past week).
My post started with something I wrote on Twitter that got me roasted yesterday, mainly for making an absolute statement that people didn't agree with, so I wanted to add a longer explanation:
😅 The perils of expressing yourself on Twitter!
one line triangle using conic-gradient : jsfiddle.net/mwfskaLx/1/.. useful if we want to think angles instead of dimension
Also with mask jsfiddle.net/mwfskaLx/2/ and jsfiddle.net/mwfskaLx/3/
These are great options, and they would simplify considerably the
background-imagemethod. I had conic-gradient aside because Firefox didn't support it (not to mention IE). But that has changed now in FF, and this is a great use of it.Another con for
clip-pathis that you can't usebox-shadowto create a shadow (you can usefilter: drop-shadow()instead).Outside of the realm of CSS art, I reach for SVG most of the time.
I agree, but one thing:
clip-pathwill hide the shadow from a filter too.If you extend the clip-path beyond the base, you can include it.
Something like this gives you a 2px drop shadow..
jsfiddle.net/robjoeol/68d350zr/9/
Thank you for the article!
Using CSS borders, you can create any triangles of different angles (but not more than 90). It is not at all necessary to divide by 2 and be limited to only this.
jsfiddle.net/m0zwLdju/
You are correct, that's not the only way to draw a triangle using the borders. I updated the article to add a note indicating that those are the steps for that specific triangle and other triangles will be slightly different:
This is a very creative post. I like it.
Thanks!