My Authors
Read all threads
Another week on #CSSpodcast, this weeks topic is CSS Functions 😍

🧵
CSS Functions provides runtime contextual expressions that return dynamic real-time value per the state of the browser per user in that moment
- global space, no need import
- can be nested, calc(var(--var))
- typed, eg: `rotate(45px)` will not work
- keep the function live, recompute on value changes and updates
- many of them are pure functions, however, counter-example: `counter()`
1️⃣ Color functions

- `rgb()`, `rgba()`, `hsl()`, `hsla()`, `lab()`, `lch()`
- `color()` w3.org/TR/css-color-4…

✨ newer browser supports comma-less notation (css-tricks.com/no-comma-color…) Image
2️⃣ Gradient functions

- `linear-gradient()`, `repeating-linear-gradient()`
top -> bottom
- `radiant-gradient()`, `repeating-radiant-gradient()`
center -> outer
- `conic-gradient()` and `repeating-conical-gradient()`
clockwise Image
3️⃣ `attr()`

- allow you to read value from attribute of the element you are targeting Image
4️⃣ `var()`

- allow you to insert value of the CSS Custom Property Image
5️⃣ `url()`

- use for fetching assets Image
6️⃣ `image-set()`

- grab image based on resolution Image
7️⃣ Functional Selectors

- `:is()`, `:where()` `:not()`, `:lang()`, `:dir()`,
- `nth-child()`, `nth-last-child()`, `nth-of-type()`, `nth-last-of-type()`

8️⃣ Mathematical Functions

- `calc()`, `min()`, `max()`, `clamp()` Image
9️⃣ Trigonometry Functions

- `sin()`, `cos()`, `acos()`, `asin()`, `atan()`, `atan2()`, `sqrt()`, `hypot()`, `pow()`
1️⃣0️⃣ `cubic-bezier()`

🎥 check out @wgao19 's talk at engineers.sg/video/the-obsc… explaining bezier Image
1️⃣1️⃣ `steps()`

- divide the output value into equal distance steps.
- useful for animating sprites Image
1️⃣2️⃣ Shape Functions

- `path()`, `circle()`, `ellipse()`, `polygon()`, `inset()` Image
1️⃣3️⃣ Transform Functions

- scaleX(), scaleY(), scaleZ(), scale(), scale3d()
- perspective()
- translateX(), translateY(), translateZ(), translate(), translate3d()
- rotateX(), rotateY(), rotateZ(), rotate(), rotate3d()
- skewX(), skewY(), skew()
1️⃣4️⃣ Filter Functions

- blur(), brightness(), contrast(), grayscale(), hue-rotate(), invert(), opacity(), saturate(), sepia(), drop-shadow(), url() Image
1️⃣5️⃣ Grid Template Functions

- `fit-content()`, `min-max()`, `repeat()`
1️⃣6️⃣ Media Queries

- `media`, `supports` Image
1️⃣7️⃣ Vulnerabilities

- Billion Laughs Attack (drafts.csswg.org/css-variables/…)
- XSS through `url()` + `attr()` (didnt' quite understand, probably @argyleink can explain further on this) Image
Missing some Tweet in this thread? You can try to force a refresh.

Keep Current with Tan Li Hau 🤔

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!