CSS
All about styling with CSS
Todo: add more subjects
- Animation
- Crossbrowser compatibility
- Fonts (Bulletproof @font-face syntax)
- Icons
- Retina
- Forms
- Mobile first approach
- Content first, start here, work your way up
- Selectors CSS Diner
- Loading: SpinKit, PleaseWait
Animation
- Animate.css - Just-add-water CSS animations
- CSS animations performance: the untold story on GreenSock
- High performance animations on HTML5Rocks
- An introduction to CSS3 keyframe animations on Smashing Magazine
- Vivify - CSS animation library
Make use of the folowing properties, to prevent paints and ensure GPU acceleration:
- Opacity
- Translate
- Rotate
- Scale
Tools
Reset or Normalize
- awsm.css makes HTML beautiful
- Eric Meyer's Reset
- Formbase for better default styles for common input elements.
- Normalize
- HTML5 Boilerplate can be useful to, it makes use of Normalize together with some other quickstart defaults.
- Normalize Opentype adds OpenType features—ligatures, kerning, and more
- Modern Normalize normalizes modern browsers and font-sizes
- Gutenberg, a modern framework to print correctly
- Tipograf is a lightweight pure CSS typography base
Box-sizing, use it!
Just use box-sizing, on everything. It's available in all new browsers and it's awesome! Block elements (like divs) will be way more predictable when you apply it to all elements and is recommed by Paul Irish and Chris Coyier. You know how hard it is to align forms? When you use this, it won't! Just do it already!
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
More resources about the subject:
- Box-sizing awareness day on CSS-Tricks
- Box-sizing on CSS-Tricks
- Box-sizing border-box ftw by Paul Irish
- HTML5 Please on HTML5 Please
- Box-sizing polyfill on GitHub
- Box-sizing border-box for IE8 on StackOverflow
- Can I use
Using em for everything
- Using ems, use it for everything.
- Using ems for mediaqueries.
In pure CSS it can be a little time consuming, calculating everything. But with Sass it can be quite easy using this function:
@function em($target, $context: 16) {
@return ($target / $context) * 1em;
}
h1 {
font-size:em(30);
}
It's also possibly to use this approach inline like this:
h1 {
font-size:(30 / 14) * 1em;
}
More information about Calculating EMs with SCSS.
Vertical rhythm, the basics
Or baseline, is very important for the balance and readablity of a webpage. Below you can find a little example (which only works in combination with reset or normalize, of course):
body {
font-size: 100%;
line-height: 1.5em;
}
h1 {
font-size: 3em;
line-height: 1em;
margin-bottom: 0.5em;
}
p {
font-size: 1em;
line-height: 1.5em;
margin-bottom: 1.5em;
}
Todo: add more notes and information.
Also check out Modular Scale, which also has a Sass implementation: Modular Scale Calculator.
Some technical information about collapsing margins and some tricks to use can be useful.
Modulair CSS
Several approaches are available to write modulair CSS (it's a way of working, not a tool):
- SMACCS
- BEM
- Getting your head ’round BEM syntax by CSS Wizardry
- Our principles for BEM + Sass by 14islands
- Sassier (BE)Modifers by Viget
- The Evolution Of The BEM Methodology
- BEM resources
- DoCSSa
- csstyle
- DRY
- OOCS
- Working method
- Part sheets
Grids
CSS Grid
- A Complete Guide to Grid by CSS-Tricks
- Introduction to CSS Grid Layout by Firefox DevTools
Using a framework
There's a lot of choice, below a little overview with well-known frameworks you can build upon:
- 960gs
- Applepie
- Bootstrap
- Bourbon Neat
- Bulma
- Concise
- Fluid Baseline Grid
- Fluidity
- Foundation
- Golden Grid System - Grid concept
- Goldilocks
- GuideGuide2 - Grids extension for Photoshop
- Gumpy
- Gridzilla
- Jeet
- Less Framework
- Modulr
- Petal
- PopGrid
- Pure
- Semantic Grid System
- Singularity
- Skeleton
- SpaceBase
- Susy
- Taffy
- Turretcss
- UIKit
Building your own grid
Some interesting approaches for settings up your custom grid:
- Don't overthink grids
- GRID - A simple guide to responsive design
- Golden Grid System
- Golden Grid System explained
Some background information about grids and using types:
A nice micro clearfix hack:
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
Preprocessors
Sass
Todo: add some more information about Sass. For now, read this: Sass Style Guide on CSS-Tricks.
- Getting your head ’round BEM syntax on csswizardry
- Principles for BEM + Sass on 14islands blog
- Sassier (BE)Modifers on viget blog
- McGriddle is a Sass library designed to help you build based on a grid system.
- Naming UI components in OOCSS on csswizardry
- Sassy Grid
- My Current CSS and Sass Styleguide on sitepoint
- Architecture for a Sass Project on sitepoint
- A Sass Component in 10 Minutes on sitepoint
- Managing Responsive Breakpoints with Sass
- DoCCSa, Sass based CSS architecture and methodology
Nice libraries:
- Bourbon Lightweight mixin library for Sass.
- Bourbon Neat Lightweight semantic grid framework for Sass.
- Bourbon Refills Prepackaged patterns and components, built on top of Bourbon, Bitters, and Neat.
- Jeet Grid system
- Plumber adding vertical rhythm to your page.
AbsurdJS
This preprocessor is quite different from the others. Most other preprocessors are written for CSS alike formats. AbsurdJS uses a JSON format, which is what makes it so powerful. You can use JavaScript! Besides styles in JSON and JavaScript functions support it also renders very very clean CSS. For big projects this can make a lot of difference.
LESS
It's a very basic preprocessor, when you're a performance user you'll probably be better of with Stylus or Sass. When you're not, probably too, Sass is okay, Stylus is awesome.
Stylus
CSS preprocessor built on NodeJS, so quite easy to install and intergrate in your workflow. Nice tutorial on tutplus.
Modernizr
Working with Modernizr can also be quite helpful when you need to support prehistoric browsers. With this tool you can detect functionalities/features, like SVG-support, media-queries or even box-sizing. When it doesn't, you can load a shiv (some javascript) to implement a fallback.
- Modernizr
- Detect box-sizing
- Detect media-queries
- Respond A fast & lightweight polyfill for min/max-width CSS3 Media Queries (for IE 6-8, and more)
- Guide to Using Modernizr responsibly by Paul Irish on GitHub
- Todo: add a getting started tutorial/reference
Misc.
- Styling underlines
- Responsive Web-design on A Book Apart
- Sass Boilerplate on GitHub
- CSS Toggle Switch
- Fixed Table Layout
- Text background, multiline
- wysiwyg.css
- You might not need JS
- Pretty checkbox
Parallax
Icons
CSS3
- Colofilter.css
- Getting to know CSS Blend Modes
- Flexbox adventures
- Understanding Flexbox: Everything you need to know
- Using Flexbox today
- Solved by Flexbox
- A Visual Guide to CSS3 Flexbox Properties
- A Complete Guide to Flexbox