Category Archives: CSS

Winning with CSS Variables

Some cool ideas of things to do with CSS variables; now supported by all modern browsers

 

CSS variables now enjoy wide cross-browser support. But what are they and why should we use them?

Any CSS property — color, size, position, etc. — can be stored in a CSS variable. Their names are all prefixed with –, and you declare them by adding them to an element right where you add its other styles.

Read more from the source: vgpena.github.io

CSS Custom Properties and Theming

Update css variable values using JavaScript and update all stylesheet rules that reference that variable

 

Chris Coyier writes:

We posted not long ago about the difference between native CSS variables (custom properties) and preprocessor variables. There are a few esoteric things preprocessor variables can do that native variables cannot, but for the most part, native variables can do the same things. But, they are more powerful because of how they are live-interpolated. Should their values ever change (e.g. JavaScript, media query hits, etc) the change triggers immediate change on the site.

Cool, right? But still, how actually useful is that? What are the major use cases? I think we’re still seeing those shake out.

Read more from the source: CSS-Tricks

Getting to know CSS Grid Layout

CSS Grids may reduce your need for media queries

 

CSS Grid is the most critical layout feature to come to browsers since Flexbox. It allows us to escape some of the magic numbers, hacks, and workarounds that we’ve grown accustomed to using for the last 15 years. It brings simplicity to declaring layouts that will tear a chunk out of most of the major CSS frameworks, and reduce bloat in our own hand crafted styles.

If you’re not familiar with what CSS Grid is, and you’ve made it this far, it’s a layout tool that applies to a containing element which then manages how the child elements are spaced, sized, and aligned.

CSS Grid gives us powerful new abilities — most notably for layout to be aware of both horizontal and vertical space at the same time, for changes to layout not to impact markup, and the ability adapt to available space without the need for media queries.

Read more from the source: Campaign Monitor Engineering

The New System Font Stack?

As system fonts get nicer you might consider treating them like first-class citizens on your web site

 

Ire Aderinokun writes:

A few months ago, I wrote about how you can use system fonts in the browser using the built-in keywords that work with the font shorthand property (see Using System Fonts in the Browser).

Relatively recently, some websites and web applications have been adopting a new method for using system fonts in the browser. With this method, the fonts used by different systems are explicitly called themselves in the font-family property.

Read more from the source: bitsofcode