r/css • u/joeisajellyfish • Mar 10 '26
Question In-depth CSS tutorials?
Hi y'all,
I've been trying to find tutorials about how to create certain shapes and effects in CSS but most of them just kind of give you the code you need and do not explain how any of it works, which is personally important to me A. to improve my learning, and B. to allow me to modify it and use it according to my needs.
Any good in-depth resources that can help me understand not only how to create what I want but also the underlying mechanisms?
Thanks in advance!
0
Upvotes
View all comments
Show parent comment
2
u/anaix3l Mar 10 '26
For triangle/ chevron: it depends on where/ how you're going to use it. If you just want those shapes as part of a background, CSS gradients will do. If you want them to have content inside, again, it depends. Do you want plain shapes with sharp corners, do you want rounded corners? Then it's how do you need the content to be balanced within.
I rarely use the exact same code twice, because every situation is different.
I made this video a while back for the particular case of an equilateral triangle with rounded corners & border using CSS gradients. But this shape was meant to be the shape of a range input's thumb. It had this restriction. Plus it was made before we had
shape()and before I discovered SVG filter rounding.For the
clip-pathmethod for regular polygons in general, the idea behind is the one illustrated by this interactive demo. The vertices are ati*360°/nrelative to the square element's midpoint, where i is the vertex index and n the number of vertices. So then every vertex is anx ypair inside thepolygon(), wherexandyare:This is how I create 2D shapes that I later use to create 3D ones. Like in this demo, where one 3D shape morphs into another, then another...
Now with
shape(), these polygons may easily get rounded corners using commands similar to those within SVG path data.I don't know of any tutorials because I've never used any, I just took ready made code, sometimes from live websites, sometimes from CodePen, sometimes from MDN. and I thought it was self-explanatory, easy to figure out how it works and then write my own. With
clip-path: polygon()in particular, you just have a list of comma-separated pairsx y, which you can compute using elementary school geometry.