Updating a CSS Variable with JavaScript
Here’s a CSS variable (formally called a “CSS custom property“):
:root {
--mouse-x: 0px;
--mouse-y: 0px;
}
Perhaps you use them to set a position:
.mover {
left: var(--mouse-x);
top: var(--mouse-y);
}
To update those values from JavaScript, you’d:
let root = document.documentElement;
root.addEventListener(“mousemove”, e => {
root.style.setProperty(‘–mouse-x’, e.clientX + “px”);
root.style.setProperty(‘–mouse-y’, e.clientY + “px”);
});
That’s all.
See the Pen Set CSS Variable with JavaScript by Chris Coyier (@chriscoyier) on CodePen.…
The post Updating a CSS Variable with JavaScript appeared first on CSS-Tricks.
WordCamp Wilmington Cancelled Due to Hurricane Florence
MetaSlider Plugin Adds Gutenberg Block for Inserting Sliders
Why State Management, Like Redux, May Solve Your Problems
The post Why State Management, Like Redux, May Solve Your Problems appeared first on Torque.
Doc Pop News Drop: An Interview With The Co-Release Lead of WordPress 4.9.9
The post Doc Pop News Drop: An Interview With The Co-Release Lead of WordPress 4.9.9 appeared first on Torque.
How to Integrate Artificial Intelligence in the Sales Process
The post How to Integrate Artificial Intelligence in the Sales Process appeared first on Torque.
Introducing Trashy.css
It began, as many things do, with a silly conversation. In this case, I was talking with our Front End Technology Competency Director (aka “boss man”) Mundi Morgado.
It went something like this…
Mundi Morgado I want you to build a visual screen reader.”
Nathan Smith Who what now?
Mundi Morgado I want a CSS library that allows you to see the structure of a document. It shouldn’t use class so that you’re forced to focus on semantics. Also, …
The post Introducing Trashy.css appeared first on CSS-Tricks.
The Low Hanging Fruit of Web Performance
I kicked off a really poppin’ Twitter thread the other day:
What are the LOWEST hanging fruit of web performance? Nothing fancy, anyone can do, big impact.
Gzip. Optimize stuff. Reduce requests…
What are other big ones?
— Chris Coyier (@chriscoyier) August 17, 2018
So, I decided to round up all the ideas (both my own and yours) around that in a post over on the Media Temple blog.
These are the things we dive into in that post:…
The post The Low Hanging Fruit of Web Performance appeared first on CSS-Tricks.



