Search
Creating Animated, Clickable Cards With the :has() Relational Pseudo Class
25.10.2022
The CSS :has() pseudo class is rolling out in many browsers with Chrome and Safari already fully supporting it. It’s often referred to it as “the parent selector” — as in, we can select style a parent element from a …
Creating Animated, Clickable Cards With the :has() Relational Pseudo Class...
Fancy Image Decorations: Masks and Advanced Hover Effects
21.10.2022
Welcome to Part 2 of this three-part series! We are still decorating images without any extra elements and pseudo-elements. I hope you already took the time to digest Part 1 because we will continue working with a lot of gradients …
Fancy Image Decorations: Masks and Advanced Hover Effects...
Single Element Loaders: The Bars
24.6.2022
We’ve looked at spinners. We’ve looked at dots. Now we’re going to tackle another common pattern for loaders: bars. And we’re going to do the same thing in this third article of the series as we have the others …
Single Element Loaders: The Bars originally published on CSS-Tricks. You should...
Conditionally Styling Selected Elements in a Grid Container
15.6.2022
Calendars, shopping carts, galleries, file explorers, and online libraries are some situations where selectable items are shown in grids (i.e. square lattices). You know, even those security checks that ask you to select all images with crosswalks or whatever.
🧐…
Conditionally...
Cool Hover Effects That Use Background Properties
27.4.2022
A while ago, Geoff wrote an article about a cool hover effect. The effect relies on a combination of CSS pseudo-elements, transforms, and transitions. A lot of comments have shown that the same effect can be done using background …
Cool Hover Effects That Use Background Properties originally...
Web Component Pseudo-Classes and Pseudo-Elements are Easier Than You Think
28.2.2022
We’ve discussed a lot about the internals of using CSS in this ongoing series on web components, but there are a few special pseudo-elements and pseudo-classes that, like good friends, willingly smell your possibly halitotic breath before you go …
Web Component Pseudo-Classes...
7 Practical Uses for the ::before and ::after Pseudo-Elements in CSS
21.9.2021
CSS ::before and ::after pseudo-elements allow you to insert “content” before and after any non-replaced element (e.g. they work on a <div> but not an <input>). This effectively allows you to show something on a web page that might …
The post 7 Practical Uses...
CSS Pseudo Commas
30.8.2021
A bonafide CSS trick if there ever was one! @ShadowShahriar created a CodePen demo that uses pseudo-elements to place commas between list items that are displayed inline, and the result is a natural-looking complete sentence with proper punctuation.
CodePen Embed…
The post CSS Pseudo Commas...
Did You Know About the :has CSS Selector?
17.3.2021
File this under stuff you don’t need to know just yet, but I think the :has CSS selector is going to have a big impact on how we write CSS in the future. In fact, if it ever ships in …
The post Did You Know About the :has CSS Selector? appeared first on CSS-Tricks.
You can support...
Bold on Hover… Without the Layout Shift
27.7.2020
When you change the font-weight of a font, the text will typically cause a bit of a layout shift. That’s because bold text is often larger and takes up more space. Sometimes that doesn’t matter, like a vertical stack of links where the wider/bolder text doesn’t push anything...
Pseudo-elements in the Web Animations API
14.5.2020
To use the Web Animations API (e.g. el.animate()) you need a reference to a DOM element to target. So, how do you use it on pseudo-elements, which don’t really offer a direct reference? Dan Wilson covers a (newish?) part of the API itself:
const logo...
Custom Styling Form Inputs With Modern CSS Features
7.2.2020
It’s entirely possible to build custom checkboxes, radio buttons, and toggle switches these days, while staying semantic and accessible. We don’t even need a single line of JavaScript or extra HTML elements! It’s actually gotten easier lately than it has been in the past. Let’s take a look.
Here’s...
css.gg
18.12.2019
I'm not sure what to call these icons from Astrit Malsija. The title is "500+ CSS Icons, Customizable, Retina Ready & API" and the URL is "css.gg" but they aren't really named anything.
Anyway, their shtick is:
The 🌎's first icon library designed by code.
The idea is that they don't...
Creating a Maintainable Icon System with Sass
28.8.2019
One of my favorite ways of adding icons to a site is by including them as data URL background images to pseudo-elements (e.g. ::after) in my CSS. This technique offers several advantages:
They don't require any additional HTTP requests other than the CSS file.
Using the background-size property...
A Little Reminder That Pseudo Elements are Children, Kinda.
8.7.2019
Here's a container with some child elements:
<div class="container">
<div>item</div>
<div>item</div>
<div>item</div>
</div>
If I do:
.container::before {
content: "x"
}
I'm essentially doing:
<div class="container">
...
Text Wrapping & Inline Pseudo Elements
27.2.2019
I love posts like this. It's just about adding a little icon to the end of certain links, but it ends up touching on a million things along the way. I think this is an example of why some people find front-end fun and some people rather dislike it.
Things involved:
Cool [attribute] selectors that...
2019 CSS Wishlist
17.1.2019
What do you wish CSS could do natively that it can't do now? First, let's review the last time we did this in 2013.
❌ "I'd like to be able to select an element based on if it contains another particular selector"
❌ "I'd like to be able to select an element based on the content...
Solved with CSS! Logical Styling Based on the Number of Given Elements
26.7.2018
This post is the third in a series about the power of CSS.
Article Series:
Colorizing SVG Backgrounds
Dropdown Menus
Logical Styling Based On the Number of Given Elements (this post)
Did you know that CSS is Turing complete? Did you know that you can use it to do some pretty serious logical...
Drawing Images with CSS Gradients
25.6.2018
What I mean by "CSS images" is images that are created using only HTML elements and CSS. They look as if they were SVGs drawn in Adobe Illustrator but they were made right in the browser. Some techniques I’ve seen used are tinkering with border radii, box shadows, and sometimes clip-path. You...