Syntax - Tasty Web Development Treats

Hasty Treat - Uses for CSS Variables


Listen Later

In this Hasty Treat, Scott and Wes talk about CSS variables, a.k.a CSS Custom Properties - why you might want to use them, why they’re better than various preprocessor’s variables, and pitfalls to watch out for and avoid.

Kyle Prinsloo’s Freelancing & Beyond — Sponsor

Kyle Prinsloo teaches you everything you need to know about freelancing, including how to quit your job, earn a side-income and start taking control of your life. Check it out at https://studywebdevelopment.com/freelancing and use the coupon code “syntax” at checkout to get 25% off.

Show Notes

3:25 - What

  • --example-name, represent custom properties

  • called using var()

  • Overwrite with a more specific style

  • Use JavaScript to append .style.setPropert(

  • How are they scoped?

    • Just like normal CSS
    • Can be set on :root {}
    • Can be set on any element down

9:10 - Why

  • Uses:

    • Can make more sense if used semantically
    • var(–accent) vs var(–yellow)
  • Independent values for things that can’t be broken up:

    • box-shadow: 2px 2px 2px 2px red
    • transform: rotate(var(–rotate)) scale(2);
  • Inline properties can be picked up by regular CSS (color, size, etc.)

    • hey

  • Themes that can easily be changed at runtime for entire app

19:15 - Calculations

  • You can use them inside of calc()
  • Animations

20:10 - Bummers

  • Not super well supported just yet (IE 11)
  • No good fallback other than manual fallback
  • Syntax - Old Browsers, Fallbacks and Polyfills series
    • Part 1
    • Part 2
    • Part 3
  • PostCSS Custom Properties
Tweet us your tasty treats!
  • Scott’s Instagram
  • LevelUpTutorials Instagram
  • Wes’ Instagram
  • Wes’ Twitter
  • Wes’ Facebook
  • Scott’s Twitter
  • Make sure to include @SyntaxFM in your tweets
...more
View all episodesView all episodes
Download on the App Store

Syntax - Tasty Web Development TreatsBy Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

  • 4.9
  • 4.9
  • 4.9
  • 4.9
  • 4.9

4.9

977 ratings


More shows like Syntax - Tasty Web Development Treats

View all
Software Engineering Radio - the podcast for professional software developers by team@se-radio.net (SE-Radio Team)

Software Engineering Radio - the podcast for professional software developers

275 Listeners

Hanselminutes with Scott Hanselman by Scott Hanselman

Hanselminutes with Scott Hanselman

379 Listeners

The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

289 Listeners

Software Engineering Daily by Software Engineering Daily

Software Engineering Daily

626 Listeners

Talk Python To Me by Michael Kennedy

Talk Python To Me

583 Listeners

Soft Skills Engineering by Jamison Dance and Dave Smith

Soft Skills Engineering

288 Listeners

Thoughtworks Technology Podcast by Thoughtworks

Thoughtworks Technology Podcast

43 Listeners

Python Bytes by Michael Kennedy and Calvin Hendryx-Parker

Python Bytes

213 Listeners

The freeCodeCamp Podcast by freeCodeCamp.org

The freeCodeCamp Podcast

483 Listeners

CoRecursive: Coding Stories by Adam Gordon Bell - Software Developer

CoRecursive: Coding Stories

188 Listeners

Practical AI by Daniel Whitenack and Chris Benson

Practical AI

208 Listeners

The Stack Overflow Podcast by The Stack Overflow Podcast

The Stack Overflow Podcast

62 Listeners

The Real Python Podcast by Real Python

The Real Python Podcast

139 Listeners

PodRocket by LogRocket

PodRocket

60 Listeners

Oxide and Friends by Oxide Computer Company

Oxide and Friends

65 Listeners