Skip to content

Instantly share code, notes, and snippets.

View byrichardpowell's full-sized avatar

Richard Powell byrichardpowell

View GitHub Profile
@byrichardpowell
byrichardpowell / gist:3470972
Created August 25, 2012 21:03
Use a OOCSS approach
// INLINE LIST
// An inline list is an object at its most basic level, e.g
// A list where each item is displayed alongside each other
// The .list-inline class styles ONLY the style needed for this type of list
.list-inline { margin:0 0 @line 0; padding:0; display:inline-block;}
.list-inline {
> * { display:inline-block; margin:0; }
li { list-style-type:none;}
@byrichardpowell
byrichardpowell / gist:3468636
Created August 25, 2012 18:04
Use dashes to separate words in class names
/* GOOD: */
.my-class { /* Styles */ }
/* BAD: */
.myClass { /* Styles */ }
.MyClass { /* Styles */ }
.my_class { /* Styles */ }
@byrichardpowell
byrichardpowell / gist:3468310
Created August 25, 2012 17:38
Styling should be independent of markup
/* BAD: This CSS (LESS) is highly dependant on specific markup */
header { /* Styles */ }
header {
section { /* Styles */ }
h1 { /* Styles */ }
small { /* Styles */ }
nav { /* Styles */ }
input[type=search] { /* Styles */ }
@byrichardpowell
byrichardpowell / gist:3468196
Created August 25, 2012 17:28
Do not use Id's as style hooks
/* BAD: */
#header-page { /* Styles */ }
/* GOOD: */
.header-page { /* Styles */ }
@byrichardpowell
byrichardpowell / gist:3468161
Created August 25, 2012 17:23
Structure CSS Logically & Provide an index
/* 1. NORMALISE ======================================================== */
/* Normalises default styles cross browser. Like a gloabl reset but better */
/* 2. PAGE LAYOUT ==================================================== */
/* Header, footer, columns, main nav... stuff like that */
/* 3. FORMS ======================================================== */
/* Default form styles & specific forms */
/* 4. LISTS ========================================================= */
@byrichardpowell
byrichardpowell / gist:3468077
Created August 25, 2012 17:14
Use Nested Selectors wisely
/* The nav-trail object is clearly separated & namespaced using nested selectors */
.nav-trail { margin:0; padding:0; background:#ccc; }
.nav-trail {
.title { font-weigth:bold; }
ul { margin:0; padding:10px; }
li,
a { dispaly:inline-block; }
}
@byrichardpowell
byrichardpowell / gist:3467893
Created August 25, 2012 16:58
Selectors should be 3 or less levels
/* BAD: The following selectors should be avoided if possible */
.one .two .three .four { /* styles */ }
.one ul li a { /* styles */ }
.one ul a:hover { /* styles */ }
.one ul li:first-child { /* styles */ }
/* BAD: Pre-processed nested selectors */
.one {
@byrichardpowell
byrichardpowell / gist:3467313
Created August 25, 2012 15:52
Make prefixes less painful using a preprocessor
/* helpers.less */
.shadow (@x-axis: 0, @y-axis: 1px, @blur: 2px, @alpha: 0.1) {
-webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
-moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
-o-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
-ms-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
}
/* site.less */
@byrichardpowell
byrichardpowell / gist:3467258
Created August 25, 2012 15:46
Use browser prefixes correctly
.shadow { -webkit-box-shadow: 10px 10px 10px #000;
-moz-box-shadow: 10px 10px 10px #000;
-o-box-shadow: 10px 10px 10px #000;
-ms-box-shadow: 10px 10px 10px #000;
box-shadow: 10px 10px 10px #000; }
@byrichardpowell
byrichardpowell / gist:3225862
Created August 1, 2012 11:11
Prototype Pattern
DependencyMap = function( config ) {
var Map = function( config ) {
this.w = config.w;
this.h = config.h;
this.wrapper = config.wrapper;
}