Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSS without the hurt

Eoin Kelly
November 01, 2014

CSS without the hurt

A collection of eight guidelines that I use to help me write maintainable CSS

Eoin Kelly

November 01, 2014
Tweet

More Decks by Eoin Kelly

Other Decks in Technology

Transcript

  1. Categories of styles Styles that appear on every page Styles

    that appear on more than one page Styles that appear on a single page
  2. Categories of styles Styles that appear on every page Styles

    that appear on more than one page Styles that appear on a single page NB
  3. Rails tries to help… A global application.css and then one

    CSS file per controller problems no obvious place to put styles that appear on more than one page but not all
  4. Eoin tries to help… @import “variables”; @import “elements”; / /

    bare HTML elements @import “modules/header”; @import “modules/footer”; / / your modules come from your visual inspection of the page @import “grid” @import “theme”
  5. layer 0: built-in browser styles layer 1: Bare HTML elements

    super strong global defaults layer 2: modules most of your styles go in here layer 3: grid grids are all a bit hacky keep grid and modules different in HTML i.e. your “grid HTML” creates an invisible skeleton that your modules live in layer 4: themes almost never required NEVER CROSS LAYERS
  6. Ways of combining styles ways of combining styles multiple classes

    on same element e.g. <div class=“foo bar”> Scss @extend Scss @include Pick one and stick with it on a project
  7. #8 Never break these rules. Unless you need to. Then

    break them as much as you need to.