Presented by Thomas Britton / Github: tmbritton
Web Developer - Digital Web Team
tom.britton@wholefoods.com
Responsive web design (RWD) is a web design approach aimed at crafting sites to provide an optimal viewing experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from mobile phones to desktop computer monitors).
According to Wikipedia
SASS | LESS |
---|---|
Ruby | Javascript |
Compass, Bourbon | ??? |
Extensibility is the greatest benefit SASS has over LESS. More mixin frameworks exist to increase efficiency of working with SASS. At a basic level working with SASS and LESS is very similar.
...
...
The grid system requires a lot of presentational classes and wrapping containers.
Label | Layout width | Column width | Gutter width |
---|---|---|---|
Large display | 1200px and up | 70px | 30px |
Default | 980px and up | 60px | 20px |
Portrait tablets | 768px and above | 42px | 20px |
Phones to tablets | 767px and below | Fluid columns, no fixed widths | |
Phones | 480px and below | Fluid columns, no fixed widths |
Anybody know where a Samsung Galaxy Note 3 fits?
Or an iPad mini?
Or any Windows phone?
Unless you spend a lot of time overriding default styles.
Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly, particularly with the help of the Compass style library.
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
nav {
ul {
margin: 0;
padding: 0;
list-style: none;
}
li { display: inline-block; }
a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
}
nav a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. This is a great way to modularize your CSS and help keep things easier to maintain...
...as long as you have a structure when you begin and your team adheres to coding standards.
CSS has an import option that lets you split your CSS into smaller, more maintainable portions. Sass builds on top of the current CSS @import but instead of loading a file on the front-end, Sass will take the file that you want to import and combine it with the file you're importing into so you can serve a single CSS file to the web browser.
Let's say you have a couple of Sass files, _reset.scss
and base.scss
. We want to import _reset.scss
into base.scss
.
// _reset.scss
html,
body,
ul,
ol {
margin: 0;
padding: 0;
}
// base.scss
@import 'reset';
body {
font-size: 100% Helvetica, sans-serif;
background-color: #efefef;
}
html, body, ul, ol {
margin: 0;
padding: 0;
}
body {
background-color: #efefef;
font-size: 100% Helvetica, sans-serif;
}
A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. You can pass in values to make your mixin more flexible.
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.box { @include border-radius(10px); }
.box {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}
Sass has a handful of standard math operators like +
, -
, *
, /
,
and %
.
.container { width: 100%; }
article[role="main"] {
float: left;
width: 600px / 960px * 100%;
}
aside[role="complimentary"] {
float: right;
width: 300px / 960px * 100%;
}
We've created a very simple fluid grid, based on 960px. Operations in Sass let us do something like take pixel values and convert them to percentages.
.container {
width: 100%;
}
article[role="main"] {
float: left;
width: 62.5%;
}
aside[role="complimentary"] {
float: right;
width: 31.25%;
}
Compass is a Sass framework, designed to make the work of styling the web smooth and efficient. Much like Rails as a web application framework for Ruby, Compass is a collection of helpful tools and battle-tested best practices for Sass.
There's also GUIs for those so inclined.
The Compass mixins are divided into categories that can be imported as needed
This module applies the global reset to your stylesheet by simply importing it.
The Compass Typography module provides some basic mixins for common text styling patterns.
The Compass Utilities module provides some basic mixins for common styling patterns.
It processes the SCSS
partials and renders the browser-readable CSS
.
There are a couple of commands I use all the time:
compass watch
compass compile
Not everybody is a nerd or on a Unixy system.