(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.data-privacy-src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-1596564-1', 'auto'); ga('send', 'pageview');

CSS Tricks

Home » CSS Tricks

Checkerboard Reveal

2021-01-26T03:03:52+01:00January 26th, 2021|Categories: Tutorials|Tags: |

Back when I was 10, I remember my cousin visiting our house. He was (and still is) a cool kid, the kind who’d bring his own self-programmed chess game on a floppy disk. And his version of chess was just as cool as him because a piece of the board would disappear after each move. [more]

Tech Stacks and Website Longevity

2021-01-26T03:03:52+01:00January 26th, 2021|Categories: Tutorials|Tags: |

Steren Giannini in “My stack will outlive yours”: My stack requires no maintenance, has perfect Lighthouse scores, will never have any security vulnerability, is based on open standards, is portable, has an instant dev loop, has no build step and… will outlive any other stack. Jeremy Keith in “npm ruin dev”: Instead of reaching for [more]

Servers: Cool Once Again

2021-01-23T03:04:03+01:00January 23rd, 2021|Categories: Tutorials|Tags: |

There were jokes coming back from the holiday break that JavaScript decided to go all server-side. I think it was rooted in: The Basecamp gang releasing Hotwire, which looks like marketing panache around a combination of technologies. “HTML over the wire,” they say, meaning it makes the server generate and serve HTML, and leaves client-side [more]

You want minmax(10px, 1fr) not 1fr

2021-01-23T03:04:03+01:00January 23rd, 2021|Categories: Tutorials|Tags: |

There are a lot of grids on the web like this: .grid { display: grid; grid-template-columns: repeat(3, 1fr); } My message is that what they really should be is: .grid { display: grid; grid-template-columns: repeat(3, minmax(10px, 1fr)); } Why? In the former, the minimum width of the grid column is min-content, which can be awkwardly [more]


2021-01-22T03:05:53+01:00January 22nd, 2021|Categories: Tutorials|Tags: |

In my recent “Custom Properties as State” post, one of the things I mentioned was that theoretically, UI libraries, like React and Vue, could automatically map the state they manage over to CSS Custom Properties so we could use that state right there if we wanted. Someone should make a useStateWithCustomProperties hook or something to do that. #freeidea Andrew [more]

Scrollbars on Hover

2021-01-22T03:05:52+01:00January 22nd, 2021|Categories: Tutorials|Tags: |

First, scrollbars are a usability and accessibility thing. Second, a rule of thumb: if an area scrolls, it should have a visible scrollbar. But the web is a big place and I like tricks, so I’m going to cover the idea of only revealing them on hover. Even macOS itself¹ hides scrollbars by default, revealing [more]

Lightweight Form Validation with Alpine.js and Iodine.js

2021-01-21T03:04:26+01:00January 21st, 2021|Categories: Tutorials|Tags: |

Many users these days expect instant feedback in form validation. How do you achieve this level of interactivity when you’re building a small static site or a server-rendered Rails or Laravel app? Alpine.js and Iodine.js are two minimal JavaScript libraries we can use to create highly interactive forms with little technical debt and a negligible [more]