Search
When Sass and New CSS Features Collide
29.6.2020
Recently, CSS has added a lot of new cool features such as custom properties and new functions. While these things can make our lives a lot easier, they can also end up interacting with preprocessors, like Sass, in funny ways.
So this is going to be a post about the issues I’ve encountered...
Using Custom Property “Stacks” to Tame the Cascade
22.6.2020
Since the inception of CSS in 1994, the cascade and inheritance have defined how we design on the web. Both are powerful features but, as authors, we’ve had very little control over how they interact. Selector specificity and source order provide some minimal “layering” control...
Adding a Custom Welcome Guide to the WordPress Block Editor
15.6.2020
I am creating a WordPress plugin and there is a slight learning curve when it comes to using it. I’d like to give users a primer on how to use the plugin, but I want to avoid diverting users to documentation on the plugin’s website since that takes them out of the experience.
What would...
Striking a Balance Between Native and Custom Select Elements
12.6.2020
Here’s the plan! We’re going to build a styled select element. Not just the outside, but the inside too. Total styling control. Plus we’re going to make it accessible. We’re not going to try to replicate everything that the browser does by default with a native <select> element. We’re going...
How to Reverse CSS Custom Counters
11.6.2020
I needed a numbered list of blog posts to be listed with the last/high first and going down from there. Like this:
5. Post Title
4. Post Title
3. Post Title
2. Post Title
1. Post Title
But the above is just text. I wanted to do this with a semantic <ol> element.
The easy way
This can...
How to Get All Custom Properties on a Page in JavaScript
8.6.2020
We can use JavaScript to get the value of a CSS custom property. Robin wrote up a detailed explanation about this in Get a CSS Custom Property Value with JavaScript. To review, let’s say we’ve declared a single custom property on the HTML element:
html {
--color-accent: #00eb9b;
}
In JavaScript...
Custom Illustrations – A Quirky and Human Design Trend
31.5.2020
The use of custom illustrations has been a big trend recently that is not likely going anywhere soon. The deal is that artistic approaches, like old habits, always die...
The post Custom Illustrations – A Quirky and Human Design Trend appeared first on Onextrapixel
Global CSS options with custom properties
30.5.2020
With a preprocessor, like Sass, building a logical “do this or don’t” setting is fairly straightforward:
$option: false;
@mixin doThing {
@if $option {
do-thing: yep;
}
}
.el {
@include doThing;
}
Can we do that in native CSS with custom properties? Mark Otto shows...
A First Look at `aspect-ratio`
29.5.2020
Oh hey! A brand new property that affects how a box is sized! That’s a big deal. There are lots of ways already to make an aspect-ratio sized box (and I’d say this custom properties based solution is the best), but none of them are particularly intuitive and certainly not...
Tackling Authentication With Vue Using RESTful APIs
18.5.2020
Authentication (logging in!) is a crucial part of many websites. Let’s look at how to go about it on a site using Vue, in the same way it can be done with any custom back end. Vue can’t actually do authentication all by itself, —we’ll need another service for that, so we’ll be using another service...
CSS Animation Timelines: Building a Rube Goldberg Machine
12.5.2020
If you’re going to build a multi-step CSS animation or transition, you have a particular conundrum. The second step needs a delay that is equal to the duration of the first step. And the third step is equal to the duration of the first two steps, plus any delay in between. It gets more...
Working With MDX Custom Elements and Shortcodes
7.5.2020
MDX is a killer feature for things like blogs, slide decks and component documentation. It allows you to write Markdown without worrying about HTML elements, their formatting and placement while sprinkling in the magic of custom React components when necessary.
Let’s harness that magic and look...
Making dark theme switcher with PostCSS.
7.5.2020
Building a dark theme switcher that take care of users OS preferences.
The post Making dark theme switcher with PostCSS. appeared first on CSS-Tricks
How to Create Custom WordPress Editor Blocks in 2020
6.5.2020
Peter Tasker on creating blocks right now:
It’s fairly straightforward these days to get set up with the WP CLI ‘scaffold’ command. This command will set up a WordPress theme or plugin with a ‘blocks’ folder that contains the PHP and base CSS and JavaScript required to create...
Playing With (Fake) Container Queries With watched-box & resizeasaurus
5.5.2020
Heydon’s <watched-box> is a damn fantastic tool. It’s a custom element that essentially does container queries by way of class names that get added to the box based on size breakpoints that are calculated with ResizeObserver. It’s like a cleaner version of what Philip...
@property
25.4.2020
The @property is totally new to me, but I see it’s headed to Chrome, so I suppose it’s good to know about!
There is a draft spec and an “intent to ship” document. The code from that document shows:
@property --my-property {
syntax: "<color";
initial-value: green;
...
Creating Color Themes With Custom Properties, HSL, and a Little calc()
16.4.2020
Before the advent of CSS custom properties (we might call them “variables” in this article as that’s the spirit of them), implementing multiple color schemes on the same website usually meant writing separate stylesheets. Definitely not the most maintainable thing in the world. Nowadays, though,...
Jetpack Instant Search!
16.4.2020
Jetpack has had a search feature for a while. Flip it on, and it replaces your built-in WordPress search (which is functional, but not particularly good) with an Elasticsearch-powered solution that is faster and has better results. I’ve been using that for quite a while here on CSS-Tricks...
Create a Responsive CSS Motion Path? Sure We Can!
15.4.2020
There was a discussion recently on the Animation at Work Slack: how could you make a CSS motion path responsive? What techniques would be work? This got me thinking.
A CSS motion path allows us to animate elements along custom user-defined paths. Those paths follow the same structure as SVG paths....
JavaScript Picture-in-Picture API
14.4.2020
As a huge fan of media on the web, I’m always excited about enhancements to how we can control our media. Maybe I get excited about simple things like the <video> tag and its associated elements and attributes because media on the web started with custom codecs, browser extensions,...