How to have the browser pick a contrasting color in CSS
Have you ever wished you could write simple CSS to declare a color, and then have the browser figure out whether black or white should be paired with that color?
Using CSS backdrop-filter for UI Effects | CSS-Tricks
Tips and tricks on utilizing the CSS backdrop-filter property to style user interfaces. You’ll learn how to layer backdrop filters among multiple elements, and integrate them with other CSS graphical effects to create elaborate designs.
Reducing CSS complexity with the :is() pseudo-class
Last week, I finally had a reason to use the newish :is() CSS pseudo-class, and wow is it glorious!
Today, I want to show you how it can dramatically reduce selector complexity. Let’s dig in!
What :is() does The :is() pseudo-class accepts a comma-separated list of selectors, and can be used to group them together.
For example, these two selector strings do the same thing…
h1, h2, h3, h4, h5, h6 { font-weight: bold; } :is(h1, h2, h3, h4, h5, h6) { font-weight: bold; } You’re probably look at this and thinking…
Decoding CSS Selectors: :has(:not) vs :not(:has) | Polypane
CSS functions like :is(), :not() and :has() are powerful tools that make it much easier to select elements specifically. We've written before about how ::where…
One of my favorite not-so-new aspects of CSS is the :empty pseudo-class.
You can use this to target elements that have no children—either child elements or whitespace and text nodes—and style them differently than they would be otherwise.
For example, imagine you have some CSS to layout items in a row using flexbox…
.grid-flex { display: flex; gap: 1rem; } .grid-flex div { background-color: #ffdc00; border: 1px solid #665800; color: #665800; padding: 1rem 2rem; text-align: center; } And a row of items generated from an API or database or something.
Pure CSS Halftone Effect in 3 Declarations – Frontend Masters Boost
A halftone is a pattern of dots that vary in size and spacing. It's a printing technique that you normally don't see, but blown up in size, is a cool aesthetic. This is a deep dive on how it can be done in CSS alone, starting quite simply!
Victor Ayomipo experiments with the CSS `min()` function, exploring its flexibility with different units to determine if it is the be-all, end-all for responsiveness. Discover the cautions he highlights against dogmatic approaches to web design based on his findings.
Getting Started with Style Queries | CSS and UI | Chrome for Developers
Style queries allow developers to query a parent element's style values using the @container rule. In Chrome 111, style queries for CSS custom properties are landing stable. Learn how to get started with them.