Skip to main content
CSS-Tricks
  • Articles
  • Notes
  • Links
  • Guides
  • Almanac
  • Shuffle
Search

Articles Tagged
custom properties

91 Articles
{
,

}
Direct link to the article Calculate Viewport Size in CSS
custom properties functions viewport units

Calculate Viewport Size in CSS

A way to calculate the viewport’s width and height without JavaScript, by way of Temani Afif over at CSS Tip:

@property --_w {
  syntax: '<length';
  inherits: true;
  initial-value: 100vw; 
}
@property --_h {
  syntax: '<length';
  inherits: true;
  
…
Avatar of Geoff Graham
Geoff Graham on Jul 17, 2024
Direct link to the article “If” CSS Gets Inline Conditionals
custom properties selectors

“If” CSS Gets Inline Conditionals

A few sirens went off a couple of weeks ago when the CSS Working Group (CSSWG) resolved to add an if() conditional to the CSS Values Module Level 5 specification. It was Lea Verou’s X post that same day that …

Avatar of Geoff Graham
Geoff Graham on Jul 9, 2024 (Updated on Jul 19, 2024)
Direct link to the article How I Made an Icon System Out of CSS Custom Properties
custom properties Sass SVG svg icons

How I Made an Icon System Out of CSS Custom Properties

SVG is the best format for icons on a website, there is no doubt about that. It allows you to have sharp icons no matter the screen pixel density, you can change the styles of the SVG on hover …

Avatar of Louis Hoebregts
Louis Hoebregts on Sep 22, 2022 (Updated on Sep 28, 2022)
Direct link to the article Making a Real-Time Clock With a Conic Gradient Face
conic gradients custom properties dates gradients

Making a Real-Time Clock With a Conic Gradient Face

Gradients have been a part of the CSS spectrum for quite some time now. We see a lot of radial and linear gradients in a lot of projects, but there is one type of gradient that seems to be a …

Avatar of Brecht De Ruyte
Brecht De Ruyte on Sep 19, 2022
Direct link to the article Interpolating Numeric CSS Variables
@property animation custom properties

Interpolating Numeric CSS Variables

We can make variables in CSS pretty easily:

:root {
  --scale: 1;
}

And we can declare them on any element:…

Avatar of Geoff Graham
Geoff Graham on Aug 30, 2022 (Updated on Sep 1, 2022)
Direct link to the article Multi-Value CSS Properties With Optional Custom Property Values
custom properties

Multi-Value CSS Properties With Optional Custom Property Values

Imagine you have an element with a multi-value CSS property, such as transform: optional custom property values:

.el {
  transform: translate(100px) scale(1.5) skew(5deg);
}

Now imagine you don’t always want all the transform values to be applied, so some …

Avatar of Yair Even Or
Yair Even Or on Feb 11, 2022 (Updated on Feb 14, 2022)
Direct link to the article How to Make a Pure CSS 3D Package Toggle
3d css animation custom properties

How to Make a Pure CSS 3D Package Toggle

You know how you can get cardboard boxes that come totally flat? You fold ‘em up and tape ‘em to make them into a useful box. Then when it’s time to recycle them, you cut them back apart to flatten …

Avatar of Jhey Tompkins
Jhey Tompkins on Jan 12, 2022 (Updated on Jan 13, 2022)
Direct link to the article Don’t Fight the Cascade, Control It!
:is :where cascade cascade layers custom properties data attributes specificity

Don’t Fight the Cascade, Control It!

If you’re disciplined and make use of the inheritance that the CSS cascade provides, you’ll end up writing less CSS. But because our styles often comes from all kinds of sources — and can be a pain to structure and …

Avatar of Mads Stoumann
Mads Stoumann on Jan 10, 2022 (Updated on Jan 11, 2022)
Direct link to the article The surprising behavior of !important in CSS custom property values
!important custom properties

The surprising behavior of !important in CSS custom property values

Huh! I did not realize that CSS custom properties had their own resolution behavior for how !important works in their values. Uh, despite writing a guide about them. 😬 But hey it’s now updated.

Stefan Judis documents it clearly. …

Avatar of Chris Coyier
Chris Coyier on Dec 17, 2021
  • 1
  • 2
  • 3
  • ...
  • 11
  • Older

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • About DO
  • Cloudways
  • Legal stuff
  • Get free credit!
CSS-Tricks
  • Write for us!
  • Advertise with us
  • Contact us
Social
  • RSS Feeds
  • CodePen
  • Mastodon
  • X
Back to Top