Search
How I Put the Scroll Percentage in the Browser Title Bar
12.5.2020
Some nice trickery from Knut Melvær.
Ultimately the trick boils down to figuring out how far you’ve scrolled on the page and changing the title to show it, like:
document.title = `${percent}% ${post.title}`
Knut’s trick assumes React and installing an additional library. I’m sure...
Creating an Accessible Range Slider with CSS
7.5.2020
The accessibility trick is using <input type="range"> and wrestling it into shape with CSS rather than giving up and re-building it with divs or whatever and later forget about accessibility.
The most clever example uses an angled linear-gradient background making the input look like...
Click Once, Select All; Click Again, Select Normally
29.4.2020
A bonafide CSS trick from Will Boyd!
Force all the content of an element to be selected when clicked with user-select: all;
If you click a second time, let the user select just parts of the text as normal.
Second click? Well, it’s a trick. You’re really using a time-delayed...
How to Redirect a Search Form to a Site-Scoped Google Search
29.4.2020
This is just a tiny little trick that might be helpful on a site where you don’t have the time or desire to build out a really good on-site search solution. Google.com itself can perform searches scoped to one particular site. The trick is getting people there using that special syntax...
SVG, Favicons, and All the Fun Things We Can Do With Them
24.4.2020
Favicons are the little icons you see in your browser tab. They help you understand which site is which when you’re scanning through your browser’s bookmarks and open tabs. They’re a neat part of internet history that are capable of performing some cool tricks.
One very new trick is the ability...
Different Approaches to Responsive CSS Motion Path
24.4.2020
As a follow-up to Jhey’s recent post on responsive motion paths, Michelle Barker notes that another approach could be to just transform: scale() the whole dang element.
The trade-off there is that you’re scaling both the path and the element on the path at the same time; Jhey’s...
Miners Trick Stablecoin Protocol PegNet, Turning $11 Into Almost $7M Hoard
22.4.2020
The millions in tokens were later destroyed, painting a confusing picture of the attacker's motives
CSS-Only Marquee Effect
5.4.2020
You make sure the text is more than twice the width of the screen, then use negative translate animations to do the marquee movement.
You’ll probably want to aria-hidden all but one of them if you need to duplicate the text. Or, you could use a very clever CSS trick...
CSS Viewport Units
26.3.2020
Deep dive from Ahmad. I like the coverage of vmin and vmax, which I think I don't reach for as often as I should.
I'm thinking that if you are doing something highly directional (e.g. a full bleed trick), then directly using vw is necessary. On the other hand, if you're doing a calculation where...
Auto-Archival
20.3.2020
I'm sure most of us have used the ol' Wayback Machine to access some site that's gone offline. I don't actually know how it decides what sites to archive and when, but you can tell it to save pages. There is UI for it right on its homepage.
Also, there is a little trick...
Typing...
Chameleonic Header
26.2.2020
Nice demo from Sebastiano Guerriero. When a fixed-position header moves from overlapping differently-colored backgrounds, the colors flop out to be appropriate for that background. Sebastiano's technique is very clever, involving multiple copies of the header within each section (where the copies...
In-Browser Performance Linting With Feature Policies
26.2.2020
Here’s a neat idea from Tim Kadlec. He uses the Modheader extension to toggle custom headers in his browser. It also lets him see when images are too big and need to be optimized in some way. This is a great way to catch issues like this in a local environment because browsers will throw an error...
Full-Width Elements By Using Edge-to-Edge Grid
7.2.2020
If you have a limited-width container, say a centered column of text, "breaking out" of that to make a full-width element involves trickery. Perhaps the best trick is the one with left relative positioning and a negative left viewport-based margin. While it has it's caveats (e.g. requiring hidden...
Searching the Jamstack
22.1.2020
Here's Raymon Camden on adding site search functionality to a site that is statically hosted. A classic trick! Just shoot 'em to Google and scope the results to your site:
<form action="https://www.google.com/search" method="get"<input type="search" name="q"...
A Trick That Makes Drawing SVG Lines Way Easier
14.1.2020
When drawing lines with SVG, you often have a <path> element with a stroke. You set a stroke-dasharray that is as long as the path itself, as well as a stroke-offset that extends so far that you that it's initially hidden. Then you animate the stroke-offset back to 0 so you can watch...
Dark Mode Favicons
4.12.2019
Oooo! A bonafide trick from Thomas Steiner. Chrome will soon be supporting SVG favicons (e.g. <link rel="icon" href="/icon.svg">). And you can embed CSS within an SVG with a <style> element. That CSS can use a perfers-color-sceme media query, and as a result, a favicon that supports...
Masking GIFs with other GIFs
3.12.2019
The other day, Cassie Evans tweeted a really neat trick that I’ve never seen before: using SVG to mask one GIF on top of another. The effect is quite lovely, especially if you happen to grab a colorful GIF and place it on top of a monochrome one:
See the Pen
Masking gifs with other gifs......
iOS 13 Broke the Classic Pure CSS Parallax Technique
27.11.2019
I know. You hate parallax. You know what we should hate more? When things that used to work on the web stop working without any clear warning or idea why.
Way back in 2014, Keith Clark blogged an exceptionally clever CSS trick where you essentially use a CSS transform to scale an element down...
Playing Sounds with CSS
25.11.2019
CSS is the domain of styling, layout, and presentation. It is full of colors, sizes, and animations. But did you know that it could also control when a sound plays on a web page?
This article is about a little trick to pull that off. It’s actually a strict implementation of the HTML and CSS,...
The Trick to Animating the Dot on the Letter “i”
4.11.2019
Here’s the trick: by combining the Turkish letter "ı" and the period "." we can create something that looks like the letter "i," but is made from two separate elements. This opens us up to some fun options to style or animate the dot of the letter independently from the stalk. Worried about...