In this post, we are going to see different methods to draw a triangle in CSS. We will focus on three in particular: the traditional method using b...
For further actions, you may consider blocking this person and/or reporting abuse
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!
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:
Another con for
clip-path
is that you can't usebox-shadow
to 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-path
will 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/
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-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.This is a very creative post. I like it.
Thanks!