CSS by T. Afif 's Avatar

CSS by T. Afif

@css-only.dev.bsky.social

๐—–๐—ฆ๐—ฆ stuff by ๐—ง๐—ฒ๐—บ๐—ฎ๐—ป๐—ถ ๐—”๐—ณ๐—ถ๐—ณ ๐Ÿ’ก https://css-tip.com ๐Ÿงฉ https://css-shape.com ๐Ÿ’ซ https://css-loaders.com ๐Ÿ“ https://css-articles.com โš™๏ธ https://css-generators.com ๐Ÿ† https://css-challenges.com ๐ŸŽจ https://css-pattern.com ๐ŸŽจ https://css-only.art

5,996 Followers  |  77 Following  |  443 Posts  |  Joined: 01.05.2023  |  2.3149

Latest posts by css-only.dev on Bluesky

I tried to add a third C to CSS but I didn't succeed. Two Cs should be enough, right?

08.08.2025 10:33 โ€” ๐Ÿ‘ 9    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Here is an overview of the CSS code: A simple keyframes and one animation declaration.

Another use case for the new sibling-*() functions and the linear() function.

07.08.2025 18:20 โ€” ๐Ÿ‘ 7    ๐Ÿ” 3    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Method #347 to "vertically center content" unlocked!

(Firefox users can use min-height: 100% instead of height: stretch)

07.08.2025 22:18 โ€” ๐Ÿ‘ 16    ๐Ÿ” 4    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Here is an overview of the CSS code: A simple keyframes and one animation declaration.

Another use case for the new sibling-*() functions and the linear() function.

07.08.2025 18:20 โ€” ๐Ÿ‘ 7    ๐Ÿ” 3    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Video thumbnail

๐Ÿ’ก CSS Tip!

How would you create the below animation? A complex keyframes? A different delay for each item?

Thanks to modern CSS, we can do it with a simple and flexible code.

css-tip.com/sequential-a...

No delays, no magic numbers, and it works with any number of items.

07.08.2025 10:23 โ€” ๐Ÿ‘ 9    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 1
Screenshot from a complex CSS Spec

Screenshot from a complex CSS Spec

Screenshot from a complex CSS Spec

Screenshot from a complex CSS Spec

Wait until you have to read (and understand) the "flex base size" and the "hypothetical main size" that you will need later to calculate the "flexible length"

07.08.2025 09:01 โ€” ๐Ÿ‘ 4    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Preview
Get the number of auto-fit/auto-fill columns in CSS The whole point of auto-fit and auto-fill is that you aren't saying how many columns to use. But if you knew how many the browser chose, you can make nice design decisions.

I have a new article out on @frontendmasters.com: get the number of auto-fit/ auto-fill columns in #CSS
frontendmasters.com/blog/count-a...

Check it out, I can assure you you'll probably learn something new. At the very least that some issues have recently been fixed... ๐Ÿ˜ผ

06.08.2025 16:00 โ€” ๐Ÿ‘ 34    ๐Ÿ” 8    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Post image

๐Ÿšจ New Course Alert ๐Ÿšจ
DevTools for Beginners

@kevinpowell.co and I just released a brand new (and totally free!) email course all about DevTools and how to use them in ways that actually help you debug and improve your CSS.

๐Ÿ”— Full details and free signup here: devtoolsforbeginners.kevinpowell.co

06.08.2025 15:10 โ€” ๐Ÿ‘ 27    ๐Ÿ” 7    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Cascading Stretch ๐Ÿ‘€

Demo: codepen.io/t_afif/pen/r...

06.08.2025 10:30 โ€” ๐Ÿ‘ 16    ๐Ÿ” 3    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 1

๐Ÿ“ New CSS Article!

Do you want to have an overview of what modern CSS can do? Check my latest article @frontendmasters.com

frontendmasters.com/blog/infinit...

Learn how I made that infinite marquee animation with less than 10 lines of CSS using shape(), sibling-index(), and more!

04.08.2025 19:01 โ€” ๐Ÿ‘ 57    ๐Ÿ” 8    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 1

๐Ÿ“ New CSS Article!

Do you want to have an overview of what modern CSS can do? Check my latest article @frontendmasters.com

frontendmasters.com/blog/infinit...

Learn how I made that infinite marquee animation with less than 10 lines of CSS using shape(), sibling-index(), and more!

04.08.2025 19:01 โ€” ๐Ÿ‘ 57    ๐Ÿ” 8    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 1

I always post full url with https and it's the case here

01.08.2025 11:42 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Video thumbnail

๐Ÿ’ก CSS Tip!

Create an infinite logo marquee using modern CSS and less than 10 lines of code.

css-tip.com/logo-marquee/

Where's the novelty, you might ask? It's responsive, works with any number of images, doesn't rely on magic numbers, and you can easily control it using CSS variables.

29.07.2025 11:03 โ€” ๐Ÿ‘ 64    ๐Ÿ” 11    ๐Ÿ’ฌ 3    ๐Ÿ“Œ 2
Overview of the CSS code from the linked post

Overview of the CSS code from the linked post

7 random images place around a circle

7 random images place around a circle

๐Ÿ’ก CSS Tip!

Do you know that you can use offset() to place images around a circle? And if you combine it with the new sibling-*() functions, you can have a perfect placement that works for any number of elements!

css-tip.com/images-circle/

17.07.2025 14:14 โ€” ๐Ÿ‘ 26    ๐Ÿ” 7    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 2

๐Ÿ˜Ž

30.07.2025 18:57 โ€” ๐Ÿ‘ 8    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

The technique is not limited to image elements. It works with any kind of content.

30.07.2025 11:23 โ€” ๐Ÿ‘ 15    ๐Ÿ” 3    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Overview of the CSS code from the link in the original post

Overview of the CSS code from the link in the original post

Another use case for modern CSS features (shape(), sibling-index(), sibling-count(), etc).

29.07.2025 11:03 โ€” ๐Ÿ‘ 5    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Video thumbnail

๐Ÿ’ก CSS Tip!

Create an infinite logo marquee using modern CSS and less than 10 lines of code.

css-tip.com/logo-marquee/

Where's the novelty, you might ask? It's responsive, works with any number of images, doesn't rely on magic numbers, and you can easily control it using CSS variables.

29.07.2025 11:03 โ€” ๐Ÿ‘ 64    ๐Ÿ” 11    ๐Ÿ’ฌ 3    ๐Ÿ“Œ 2

Never heard about such element ๐Ÿซฃ

I still have 0 reading/knowledge about the "custom select" thing.

27.07.2025 00:01 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

They require both arguments to have the same type (length in this case) but you can also have them unitless (number or integer) and it works too.

max(0,500) works too BUT it should be applied to a property that accept an integer/number.

mixing the types is the issue.

25.07.2025 08:00 โ€” ๐Ÿ‘ 6    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

We can also have a nice entry animation by adding the following code:

```
img {
transition: 1s 1s;
@โ€‹starting-style {
offset: circle(0px) 0% 0deg;
}
}
```

Demo: codepen.io/t_afif/full/... via @codepen.io

18.07.2025 09:41 โ€” ๐Ÿ‘ 70    ๐Ÿ” 13    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 1

We can also have a nice entry animation by adding the following code:

```
img {
transition: 1s 1s;
@โ€‹starting-style {
offset: circle(0px) 0% 0deg;
}
}
```

Demo: codepen.io/t_afif/full/... via @codepen.io

18.07.2025 09:41 โ€” ๐Ÿ‘ 70    ๐Ÿ” 13    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 1

Here is a demo where you can add/remove images and see how they align perfectly.

Demo: codepen.io/t_afif/full/... via @codepen.io

As a bonus, we can have a nice animation by adding a transition to the offset property.

17.07.2025 19:20 โ€” ๐Ÿ‘ 9    ๐Ÿ” 2    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Overview of the CSS code from the linked post

Overview of the CSS code from the linked post

7 random images place around a circle

7 random images place around a circle

๐Ÿ’ก CSS Tip!

Do you know that you can use offset() to place images around a circle? And if you combine it with the new sibling-*() functions, you can have a perfect placement that works for any number of elements!

css-tip.com/images-circle/

17.07.2025 14:14 โ€” ๐Ÿ‘ 26    ๐Ÿ” 7    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 2

We can also create a custom function and make the code easier to use.

โš ๏ธ No browser support yet, but it's on the way! โš ๏ธ

15.07.2025 09:13 โ€” ๐Ÿ‘ 8    ๐Ÿ” 3    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

We can also create a custom function and make the code easier to use.

โš ๏ธ No browser support yet, but it's on the way! โš ๏ธ

15.07.2025 09:13 โ€” ๐Ÿ‘ 8    ๐Ÿ” 3    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Overview of the CSS code from the linked post

Overview of the CSS code from the linked post

๐Ÿ’ก CSS Tip!

Using modern CSS features such as sibling-index() and if(), you can re-create the :nth-child(An + B) selector.

css-tip.com/nth-child/

Why? To easily update A and B since now they are variables! I know some of you are in the team: "How to update the values of nth-child() with CSS ?!"

14.07.2025 10:56 โ€” ๐Ÿ‘ 17    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 1
Overview of the CSS code from the linked post

Overview of the CSS code from the linked post

๐Ÿ’ก CSS Tip!

Using modern CSS features such as sibling-index() and if(), you can re-create the :nth-child(An + B) selector.

css-tip.com/nth-child/

Why? To easily update A and B since now they are variables! I know some of you are in the team: "How to update the values of nth-child() with CSS ?!"

14.07.2025 10:56 โ€” ๐Ÿ‘ 17    ๐Ÿ” 1    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 1

oops, this suddenly makes the function feature kind of useless now ๐Ÿ˜…

That example was a simplified test case but in reality I want many local variables to be typed to do various calculation.

looks like the "hacky" solution is to add all the local variabled as arguments at the end of the function ๐Ÿค”

14.07.2025 08:35 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

sibling-index() inside function works fine (I tried it with other examples). The issue is its usage with if(). when I introduce if() it breaks and the exact same code outside a function works fine.

I hope it's a bug because I don't see why it should not work.

13.07.2025 22:05 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

@css-only.dev is following 20 prominent accounts