SlideShare ist ein Scribd-Unternehmen logo
1 von 84
Downloaden Sie, um offline zu lesen
Fasten RWD Development
with Sass
Sven Wolfermann | maddesigns
Who is the guy?
· Sven Wolfermann (36)
· Freelancer for modern frontend
development (RWD, HTML5, CSS3)
from Berlin
· CSS3 Adventskalender 2010/2011
· wrotes articles for T3N, PHP-Magazin
and Webstandards-Magazin
(new: Screengui.de)
· Certified TYPO3 Integrator
· Twitter: @maddesigns
· Web: http://maddesigns.de
CSS
IS
AWESOME
old

new
http://sass-lang.com/
What is Sass?
Sass means syntactically awesome style sheets
is a preprocessor
Similar preprocessors: LESS, Stylus (needs JS, i.e. a node.js server
Installing Sass
In order to install and run Sass, you need to have Ruby installed on your system.

Mac OSX
Easy! Ruby is built in :)

Linux
if not installed, use the package manager
$ sudo apt-get install ruby1.9.1-full

on Windows?
use http://rubyinstaller.org/ to install ruby
Installing Sass
$ sudo gem install sass

install beta version:
$ sudo gem install sass --pre

already installed Sass?
check with
$ sass --version
Create your first Sass (SCSS) file
create a sass folder
create styles.scss
open in your favourite editor*

* Sublime Text 2
Wait? What is the SCSS-thingy?
Sass or SCSS?
Sass has two syntaxes. The new main syntax is known as “SCSS” (for
“Sassy CSS”). SCSS files use the extension .scss.
The second, older syntax is known as the indented syntax (or just
“Sass”). Instead of brackets and semicolons, it uses the indentation of
lines to specify blocks. Files in the indented syntax use the extension
.sass.
SCSS
section {
margin: 1em 0;
header {
background-color: lightpink;
}
}

Sass
section
margin: 1em 0
header
background-color: lightpink
compiling to CSS - watch changes
open terminal
$ sass input.scss output.css

watch folder
$ sass --watch sass:css

watch file
$ sass --watch sass/style.scss:css/style.css
GUIs
many GUIs for compiling
· Livereload ($9.99)
· Fire.App ($14)
· Compass.app ($10)
· CodeKit ($28)
· Prepros ($19)
· Scout App (free)
and build in in many text editors or IDEs
Compiling output styles
:compressed
// sass --watch sass:css --style compressed
html,body{height:100%}.container{min-height:100%;max-width:1200px;width:auto;margin:

:compact
// sass --watch sass:css --style compact
html, body { height: 100%; }
.container { min-height: 100%; max-width: 1200px; width: auto; margin: 0 auto; padding
.container h1 { border-bottom: 2px solid black; color: #ff8700; margin: 0 0 0.5em; }
Compiling output styles
:nested
// sass --watch sass:css --style nested
html,
body {
height: 100%; }
.container {
min-height: 100%;
max-width: 1200px;
width: auto;
margin: 0 auto;
padding: 0 20px; }
.container h1 {
border-bottom: 2px solid black;
color: #ff8700;
margin: 0 0 0.5em; }
Compiling output styles
:expanded
// sass --watch sass:css --style expanded
html,
body {
height: 100%;
}
.container {
min-height: 100%;
max-width: 1200px;
width: auto;
margin: 0 auto;
padding: 0 20px;
}
.container h1 {
border-bottom: 2px solid black;
color: #ff8700;
margin: 0 0 0.5em;
}
Compiling output with line numbers
:line-numbers
// sass --watch sass:css --style expanded --line-numbers
...
/* line 12, ../sass/style.scss */
.container {
min-height: 100%;
max-width: 1200px;
width: auto;
margin: 0 auto;
padding: 0 20px;
}
/* line 19, ../sass/style.scss */
.container h1 {
border-bottom: 2px solid black;
color: #ff8700;
margin: 0 0 0.5em;
}
Debugging in Sass 3.3
Sourcemaps to work with original files in developer tools
scss --sourcemap sass/styles.scss public/styles.css

Include in Sass:
/*# sourceMappingURL=styles.css.map */

Sassmaps output
{
"version": "3",
"mappings": "4DAUA,qFAWQ,CACJ,OAAO,CAAE,KAAK,CAOlB,…",
"sources": ["../sass/_vars.css”,”../sass/styles.scss"],
"file": "styles.css"
}
Variables
working with variables
h1 {
border-bottom: 2px solid #000000; // black
color: #FF8700; // orange
margin: 0 0 0.5em;
}

SCSS

change to global variables
$brand-color1: #000000;
$brand-color2: #FF8700;
h1 {
border-bottom: 2px solid $brand-color1;
color: $brand-color2;
margin: 0 0 0.5em;
}

SCSS
Variables
variables can be colors, sizes, percentage, ...
$page_max_width: 1200px;
$padding: 20px;

SCSS

.container {
min-height: 100%;
max-width: $page_max_width;
width: auto;
margin: 0 auto;
padding: 0 $padding;
}

SCSS
Calculating with Sass
SCSS
.container {
max-width: $page_max_width - $padding * 2;
padding: 0 $padding;
...
}

CSS
.container {
max-width: 1160px; /* 1200px - 20px * 2 */
padding: 0 20px;
...
}

SCSS
Nesting
Nesting
writing long selectors is time consuming
short selectors are better in general
CSS
nav
nav
nav
nav
nav

{float: right;}
li {float: left;}
li a {color: #666;}
li a:hover {color: #333;}
li.current {font-weight: bold;}
Nesting
SCSS
nav {
float: right;
li {
float: left;
a {
color: #666;
&:hover {
color: #333;
}
}
&.current {
font-weight: bold;
}
}
}

SCSS
Nesting
identation with SCSS makes no difference in CSS output
SCSS
nav {float: right;
li {float: left;
a {color: #666;
&:hover {
color: #333;}
}
&.current {
font-weight: bold;}
}}

but sure it looks better if intended

SCSS
Nesting
HOW DEEP CAN I GO?
Sass nesting != HTML nesting
be careful with nesting!
you can run into performance issues with long selectors
Combining Selectors
Combining Selectors
div {
color: black
.foo {
color: black } //
+ .foo {
color: black } //
//
> .foo {
color: black } //
~ .foo {
color: black } //
//
& .foo {
color: black } //
//
&.bar {
color: black }
&:hover {
color: black }
}

SCSS

descendant
adjacent
sibling
child
general
sibling
Sass' parent
selector

div {
color: black; }
div .foo {
color: black; }
div + .foo {
color: black; }
div > .foo {
color: black; }
div ~ .foo {
color: black; }
div .foo {
color: black; }
div.bar {
color: black; }
div:hover {
color: black; }
Parent Selector - the ampersand
the & (ampersand) has a placeholder function for the parental selector
div {
.foo {
color: black
}
&.foo {
color: black
}
}

div .foo {
color: black
}
div.foo {
color: black;
}

SCSS
Parent Selector - the ampersand
a {
&:hover,
&:focus {
color: black
}
}

a:hover, a:focus {
color: black;
}

SCSS
Parent Selector - the ampersand
Usecase for Modernizr classes
div {
box-shadow: 0 0 5px rgba(#000, 0.8);
// Sass feature for Hex to RGB colors
.no-boxshadow & {
border: 1px solid #555;
}
}

div {
box-shadow: 0 0 5px rgba(#000, 0.8); }
.no-boxshadow div {
border: 1px solid #555; }

SCSS
Parent Selector - the ampersand
div {
.parent & .child {
color: black
}
}

.parent div .child {
color: black;
}

SCSS
Parent Selector - the ampersand
@media queries in place
aside {
width: 100%;
@media screen and (min-width: 680px) {
width: 25%;
}
}

aside {
width: 100%;
}
@media screen and (min-width: 680px) {
aside {
width: 25%;
}
}

SCSS
BTW did you recognize the Comments?
/* Hey look at this multiline comment
* that we want to show up in our CSS output. */
.container {
color: black; }
// These comments are single lines and
// we do not want them to appear in our CSS
footer {
color: #336699; }

This compiles to:
/* Hey look at this multiline comment
* that we want to show up in our CSS output. */
.container {
color: black; }
footer {
color: #336699; }

SCSS
Importing Files
Importing
the way in CSS
/* style.css */
@import "base.css";
@import url("styles.css");
@import url("druck.css") print;

Importing CSS files into one file can cause performance issues
Limit your external references in your HTML
Importing in Sass is better
split your stylesheet in many chunks and use the import function of
Sass
Importing
@import "modules/base";
@import "partials/header", "partials/footer";

SCSS

create subfolders and devide into partials
use underscore in your filenames to concatinate the partials within the
compiling process
Importing
Imagine this structure
/style.sass
/modules/
┗ _normalize.sass
┗ _base.sass
┗ _mixins.sass
/partials/
┗ _footer.sass
┗ _header.sass
/ie.sass
/print.sass

none underscore files will be compiled into seperate CSS files
Importing
# style.sass
@import modules/normalize
@import modules/base
@import modules/mixins
@import partials/header
@import partials/footer
@import ie
@import print

this compiles to 3 files:
/css
┗ style.css
┗ ie.css
┗ print.css

SCSS
@extend
@extend
@extend clones the attributes from rules and adds them to another
rule.
.button {
background-color: $color-main;
font-weight: bold;
color: white;
padding: 5px;
}

SCSS

Then we can @extend the class to another
.button-checkout {
@extend .button;
background-color: darken($color-main, 20%);
}

SCSS
@extend
.button-checkout {
@extend .button;
background-color: darken($color-main, 20%);
.msg & {
@extend .button;
background-color: darken($color-main, 30%);
}
}

.button, .button-checkout, .msg .button-checkout {
background-color: blue;
font-weight: bold;
color: white;
padding: 5px; }
.button-checkout {
background-color: #000099; }
.msg .button-checkout {
background-color: #000066; }

SCSS
Placeholder Selectors: %foo
// This ruleset won't be rendered on its own.
%button {
color: blue;
font-weight: bold;
font-size: 2em; }

SCSS

placeholder selectors can be extended, just like classes and IDs. The
extended selectors will be generated, but the base placeholder selector
will not
.btn-notice { @extend %button; }

.btn-notice {
color: blue;
font-weight: bold;
font-size: 2em; }

SCSS
%placeholder
placeholder selectors will not be rendered to CSS.
%button {
background-color: $color-main;
font-weight: bold;
color: white;
padding: 5px;
}
.button-checkout {
@extend %button;
background-color: darken($color-main, 20%);
}

.button-checkout {
background-color: #000099;
font-weight: bold;
color: white;
padding: 5px; }

SCSS
@mixin
Man, tell me the cool things!
Mixins
Are code snippets (reusable elements)
Parameterizable (use reasonable defaults)
@mixin border-radius($value) {
-webkit-border-radius: $value;
-moz-border-radius: $value;
border-radius: $value;
}
.box {
color: $color-main;
font-family: $helvetica-font-stack;
@include border-radius(5px);
}

SCSS
Mixins
compiled to
.box {
color: blue;
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}

but thats a bad example – no need for the vendor prefixes of borderradius anymore
only use border-radius: 5px; in your stylesheets
Mixins
Defaults and named arguments
@mixin link-colors($text:blue, $hover:red) {
color: $text;
&:hover { color: $hover; }
}
a {
@include link-colors($hover: green);
}

a { color: blue; }
a:hover { color: green; }

SCSS
Mixins
SCSS
@mixin my-btn($color) {
color: $color;
}
@include my-btn(red);

SCSS

Sass
=my-btn($color)
color: $color
+my-btn(red)

SCSS
Using @content
@mixin ie6 {
* html & {
@content;
}
}
.m-login {
float: right;
@include ie6 {
display: inline;
}
}

.m-login {
float: right;
}
* html .m-login {
display: inline;
}

SCSS
Functions
Functions
Operators
Relational operators (<, >, <=, >=) evaluate numbers
1 < 20 // true
10 <= 20 // true
4 > 1 // true
4 >= 1 // true

SCSS

Comparison operators (==, !=) evaluate all data types
1 + 1 == 2 // true
small != big // true
#000 == black // true

SCSS
Functions
Control Directives
@if
@for
@each
@while
$theme: ocean;
div {
@if $theme == dusty {
background: #c6bba9;
color: $color;
} @else if $theme == ocean {
background: blue;
color: white;
}
}

SCSS
Functions
@for loop
@for $level from 0 to 5 {
.tag-#{$level + 1} {
font-size: .7em + ($level * .5em);
}
}

.tag-1
.tag-2
.tag-3
.tag-4
.tag-5

{
{
{
{
{

font-size:
font-size:
font-size:
font-size:
font-size:

0.7em;
1.2em;
1.7em;
2.2em;
2.7em;

}
}
}
}
}

SCSS
Functions
User Functions
@function grid-width($cells) {
@return ($cell-width + $cell-padding) * $cells;
}

SCSS

Function to calculate the em font size from pixels
@function px2em($font_size, $base_font_size: 16) {
@return $font_size / $base_font_size + em
}

SCSS
Media-Queries with Sass
Variables in queries
use main breakpoints as variables
$break-small: 320px;
$break-large: 1200px;
.profile-pic {
float: left;
width: 100px;
@media screen and (min-width: $break-small) {
width: 250px;
float: none;
}
@media screen and (min-width: $break-large) {
float: right;
}
}

Responsive Web Design in Sass: Using Media Queries in Sass 3.2

SCSS
Mixin for different media queries using @content
SCSS

$break-small: 320px;
$break-large: 1200px;
@mixin respond-to($media) {
@if $media == smartpones {
@media only screen and (max-width:
@content;
}
} @else if $media == tablet {
@media only screen and (min-width:
and (max-width:
@content;
}
} @else if $media == desktop {
@media only screen and (min-width:
@content;
}
}
}

$break-small) {

$break-small + 1)
$break-large - 1) {

$break-large) {
Mixin for different media queries using @content
Usage
// profile picture module
.profile-pic {
float: left;
width: 250px;
@include respond-to(smartpones) { width: 100% ;}
@include respond-to(tablet) { width: 125px; }
@include respond-to(desktop) { float: none; }
}

SCSS
Mixin for different media queries using @content
CSS output sample
.profile-pic {
float: left;
width: 250px;
}
@media only screen and (max-width: 320px) {
.profile-pic {
width: 100%;
}
}
@media only screen and (min-width: 321px) and (max-width: 1199px) {
.profile-pic {
width: 125px;
}
}
@media only screen and (min-width: 1200px) {
.profile-pic {
float: none;
}
}
mobile first and IE8
Sass-IE
Writing mobile-first styles without leaving IE < 9 behind
Media Query Mixin:
// all.scss
$fix-mqs: false !default;
@mixin respond-min($width) {
// If we're outputting for a fixed media query set...
@if $fix-mqs {
// ...and if we should apply these rules...
@if $fix-mqs >= $width {
// ...output the content the user gave us.
@content;
}
}
@else {
// Otherwise, output it using a regular media query
@media screen and (min-width: $width) {
@content;
}
}
}
// and a respond-max mixin, that does what you might expect
Sass-IE
Sass-IE
OldIE Mixin:
// all.scss
$old-ie: false !default;
@mixin old-ie {
// Only use this content if we're dealing with old IE
@if $old-ie {
@content;
}
}

Separate IE stylesheet
// all-old-oldie.scss
$old-ie: true;
$fix-mqs: 65em;
@import 'all';
Including the Sass-IE CSS
To give the CSS to the browsers, use good old conditional comments:
<!--[if lte IE 8]>
<link rel="stylesheet" href="css/all-old-ie.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="css/all.css">
<!--<![endif]-->
http://compass-style.org/
Compass
Compass is to Sass like jQuery to Javascript
Compass is a Framework, that extends Sass
It brings a lot of CSS3 mixins and useful CSS stuff

http://sonspring.com/journal/sass-for-designers
Compass Plugins
Github List of Compass Plugins
loading Compass plugins
add to the config.rb
# config.rb
...
require 'compassplugin'

@import 'compassplugin';

SCSS
RGBAPNG Plugin
Compass plugin for providing cross-browser compatible RGBA support
by creating transparent PNGs on the fly for browsers that don't support
RGBA.
https://github.com/aaronrussell/compass-rgbapng
$ sudo gem install compass-rgbapng

@import "rgbapng";
.box {
@include rgba-background(rgba(0,0,0,0.75));
}

.box {
background: url('/images/rgbapng/000000bf.png?1282127952');
background: rgba(0, 0, 0, 0.75); }

SCSS
Compass plugins
Responsive Grid Plugin – Susy
$ sudo gem install compass-susy-plugin
$ compass create myproject -r susy -u susy

Add Susy plugin to existing projects
# config.rb
require "susy"
Susy Usage
SCSS

@import "susy";
// global variables
$total-columns: 12;
$column-width: 4em;
$gutter-width: 1em;
$grid-padding: $gutter-width;

//
//
//
//

// usage
.page {
@include container;
@include susy-grid-background;
}

a 12-column grid
each column is 4em wide
1em gutters between columns
grid-padding equal to gutters
Susy Usage
.page {
// page acts as a container for our grid.
@include container;
// header and footer are full-width by default.
header, footer { clear: both; }
// nav spans 3 columns of total 12.
nav { @include span-columns(3,12); }
.content {
// content spans the final (omega) 9 columns of 12.
@include span-columns(9 omega,12);
// main content spans 6 of those 9 columns.
.main { @include span-columns(6,9); }
// secondary content spans the final 3 (omega) of 9 columns.
.secondary { @include span-columns(3 omega,9); }
}
}
Compass plugins
Responsive Grid Plugin – Singularity – Grids without limits
$ sudo gem install singularitygs
$ compass create myproject -r singularitygs --using singularitygs

Add Singularity plugin to existing projects
# config.rb
require "singularitygs"

@import 'singularitygs';
Symmetric Grids - Twitter Bootstrap
$grids: 12;
$gutters: 1/3;

Responsive Grids by @snugug
Symmetric Grids - Zurb Foundation
$grids: 12;
$gutters: 0.9375em;
$gutter-style: split;

Responsive Grids by @snugug
Asymetric Grids with Singularity
$grids: 1 4 1;
$gutters: 1/6;
$gutter-style: split;

Responsive Grids by @snugug
Singularity Usage
@include grid-span($span, $location);
SCSS

// Span 1 column, starting at the 2nd column
.span1-pos2 {
@include grid-span(1, 2);
}
// Span 3 columns, starting at the 3th column
.span3-pos3 {
@include grid-span(3, 3);
}
// Span 5 columns, starting at the 7th column
.span5-pos7 {
@include grid-span(5, 7);
}
Easy 12 column grid
$grids: 12;
$gutters: 12px;
$gutter-styles: 'split' 'fixed';
$output: 'float';
@for $i from 1 through $grids {
.grid#{$i} {
@include grid-span($i);
}
}

Easy 12 column grid
Compass plugins
simple media queries Sass plugin – Breakpoint
$ gem install breakpoint

Add plugin to projects
# config.rb
require "breakpoint"

// main.scss
@import "breakpoint";

SCSS
Breakpoint plugin usage
// basic media queries, min-width and min/max width
$basic: 543px;
$pair: 456px 794px;
.foo {
content: 'No Media Queries';
@include breakpoint($basic) {
content: 'Basic Media Query';
}
@include breakpoint($pair) {
content: 'Paired Media Query';
}
}

SCSS
Breakpoint plugin CSS output
/* Nested Breakpoint calls become separate media queries */
.foo {
content: 'No Media Queries';
}
@media (min-width: 543px) {
.foo {
content: 'Basic Media Query';
}
}
@media (min-width: 456px) and (max-width: 794px) {
.foo {
content: 'Paired Media Query';
}
}
Breakpoint Media Types
$breakpoint-to-ems: true;
$media: 'screen' 700px;
#foo {
@include breakpoint($media) {
content: 'Media';
}
}

@media screen and (min-width: 43.75em) {
#foo {
content: 'Media';
}
}

SCSS
Team Sass on Github
lot of Sass goodies

· Singularity
· Breakpoint
· Toolkit
· …
https://github.com/Team-Sass
Questions?

Thanks for your attention!
Sven Wolfermann | maddesigns
http://maddesigns.de/rwd-sass-compass/

HTML5 slideshow by Google

Weitere ähnliche Inhalte

Was ist angesagt?

GOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatGOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatRachel Andrew
 
The Future of Frontend - what is new in CSS?
The Future of Frontend - what is new in CSS?The Future of Frontend - what is new in CSS?
The Future of Frontend - what is new in CSS?Rachel Andrew
 
Laracon Online: Grid and Flexbox
Laracon Online: Grid and FlexboxLaracon Online: Grid and Flexbox
Laracon Online: Grid and FlexboxRachel Andrew
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyArcbees
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid LayoutRachel Andrew
 
Confoo: The New CSS Layout
Confoo: The New CSS LayoutConfoo: The New CSS Layout
Confoo: The New CSS LayoutRachel Andrew
 
Solving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJSSolving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJSRachel Andrew
 
CSS Grid Layout - All Things Open
CSS Grid Layout - All Things OpenCSS Grid Layout - All Things Open
CSS Grid Layout - All Things OpenRachel Andrew
 
Open Web Camp: CSS3 Implementable Features
Open Web Camp: CSS3 Implementable FeaturesOpen Web Camp: CSS3 Implementable Features
Open Web Camp: CSS3 Implementable FeaturesEstelle Weyl
 
CSS3 meets GWT with GSS
CSS3 meets GWT with GSSCSS3 meets GWT with GSS
CSS3 meets GWT with GSSjdramaix
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid LayoutRachel Andrew
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
CSS Conf Budapest - New CSS Layout
CSS Conf Budapest - New CSS LayoutCSS Conf Budapest - New CSS Layout
CSS Conf Budapest - New CSS LayoutRachel Andrew
 

Was ist angesagt? (20)

GOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for thatGOTO Berlin - You can use CSS for that
GOTO Berlin - You can use CSS for that
 
CSS Grid vs. Flexbox
CSS Grid vs. FlexboxCSS Grid vs. Flexbox
CSS Grid vs. Flexbox
 
The Future of Frontend - what is new in CSS?
The Future of Frontend - what is new in CSS?The Future of Frontend - what is new in CSS?
The Future of Frontend - what is new in CSS?
 
Laracon Online: Grid and Flexbox
Laracon Online: Grid and FlexboxLaracon Online: Grid and Flexbox
Laracon Online: Grid and Flexbox
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid Layout
 
Confoo: The New CSS Layout
Confoo: The New CSS LayoutConfoo: The New CSS Layout
Confoo: The New CSS Layout
 
Solving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJSSolving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJS
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
Bootstrap Framework
Bootstrap Framework Bootstrap Framework
Bootstrap Framework
 
CSS Grid Layout - All Things Open
CSS Grid Layout - All Things OpenCSS Grid Layout - All Things Open
CSS Grid Layout - All Things Open
 
Next-level CSS
Next-level CSSNext-level CSS
Next-level CSS
 
Open Web Camp: CSS3 Implementable Features
Open Web Camp: CSS3 Implementable FeaturesOpen Web Camp: CSS3 Implementable Features
Open Web Camp: CSS3 Implementable Features
 
CSS3 meets GWT with GSS
CSS3 meets GWT with GSSCSS3 meets GWT with GSS
CSS3 meets GWT with GSS
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
CSS Conf Budapest - New CSS Layout
CSS Conf Budapest - New CSS LayoutCSS Conf Budapest - New CSS Layout
CSS Conf Budapest - New CSS Layout
 
PostCss
PostCssPostCss
PostCss
 

Andere mochten auch

Responsive Typography with Sass
Responsive Typography with SassResponsive Typography with Sass
Responsive Typography with SassJames Steinbach
 
Smarter Grids with Sass and Susy
Smarter Grids with Sass and SusySmarter Grids with Sass and Susy
Smarter Grids with Sass and SusyMichelle Barker
 
Mobile Web Performance Optimization 1-7-14
Mobile Web Performance Optimization 1-7-14Mobile Web Performance Optimization 1-7-14
Mobile Web Performance Optimization 1-7-14XBOSoft
 
Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016
Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016
Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016Jesse Semchuck
 
Testing Responsive Webdesign
Testing Responsive WebdesignTesting Responsive Webdesign
Testing Responsive WebdesignSven Wolfermann
 
Amp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pagesAmp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pagesRobert McFrazier
 
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing CloudIMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing CloudAdobeMarketingCloud
 

Andere mochten auch (10)

Responsive and Fast
Responsive and FastResponsive and Fast
Responsive and Fast
 
Responsive Typography with Sass
Responsive Typography with SassResponsive Typography with Sass
Responsive Typography with Sass
 
Smarter Grids with Sass and Susy
Smarter Grids with Sass and SusySmarter Grids with Sass and Susy
Smarter Grids with Sass and Susy
 
Mobile Web Performance Optimization 1-7-14
Mobile Web Performance Optimization 1-7-14Mobile Web Performance Optimization 1-7-14
Mobile Web Performance Optimization 1-7-14
 
Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016
Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016
Google AMP - What is it and is it right for your website? SLCSEM, Oct 2016
 
WTF is AMP?
WTF is AMP?WTF is AMP?
WTF is AMP?
 
Testing Responsive Webdesign
Testing Responsive WebdesignTesting Responsive Webdesign
Testing Responsive Webdesign
 
Amp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pagesAmp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pages
 
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing CloudIMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
 
CSS Systems
CSS SystemsCSS Systems
CSS Systems
 

Ähnlich wie Fasten RWD Development with Sass

CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sassHuiyi Yan
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersSuzette Franck
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsSanjoy Kr. Paul
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compassChris Lee
 
Introducing grunt, npm and sass
Introducing grunt, npm and sassIntroducing grunt, npm and sass
Introducing grunt, npm and sasspriyanka1452
 
CSS előfeldolgozók
CSS előfeldolgozókCSS előfeldolgozók
CSS előfeldolgozókMáté Farkas
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFxStefan Bauer
 
Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Stefan Bauer
 

Ähnlich wie Fasten RWD Development with Sass (20)

CSS3
CSS3CSS3
CSS3
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress Developers
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and Cons
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compass
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Introducing grunt, npm and sass
Introducing grunt, npm and sassIntroducing grunt, npm and sass
Introducing grunt, npm and sass
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
CSS előfeldolgozók
CSS előfeldolgozókCSS előfeldolgozók
CSS előfeldolgozók
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX
 
Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan
 

Mehr von Sven Wolfermann

RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsSven Wolfermann
 
Typografie im Responsive Webdesign
Typografie im Responsive WebdesignTypografie im Responsive Webdesign
Typografie im Responsive WebdesignSven Wolfermann
 
Responsive Webdesign Process
Responsive Webdesign ProcessResponsive Webdesign Process
Responsive Webdesign ProcessSven Wolfermann
 
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)Sven Wolfermann
 
CSS3 im praktischen Einsatz
CSS3 im praktischen EinsatzCSS3 im praktischen Einsatz
CSS3 im praktischen EinsatzSven Wolfermann
 

Mehr von Sven Wolfermann (7)

Responsive Enhancement
Responsive EnhancementResponsive Enhancement
Responsive Enhancement
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
Typografie im Responsive Webdesign
Typografie im Responsive WebdesignTypografie im Responsive Webdesign
Typografie im Responsive Webdesign
 
Responsive Images
Responsive ImagesResponsive Images
Responsive Images
 
Responsive Webdesign Process
Responsive Webdesign ProcessResponsive Webdesign Process
Responsive Webdesign Process
 
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
 
CSS3 im praktischen Einsatz
CSS3 im praktischen EinsatzCSS3 im praktischen Einsatz
CSS3 im praktischen Einsatz
 

Kürzlich hochgeladen

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Kürzlich hochgeladen (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

Fasten RWD Development with Sass

  • 1. Fasten RWD Development with Sass Sven Wolfermann | maddesigns
  • 2. Who is the guy? · Sven Wolfermann (36) · Freelancer for modern frontend development (RWD, HTML5, CSS3) from Berlin · CSS3 Adventskalender 2010/2011 · wrotes articles for T3N, PHP-Magazin and Webstandards-Magazin (new: Screengui.de) · Certified TYPO3 Integrator · Twitter: @maddesigns · Web: http://maddesigns.de
  • 5. What is Sass? Sass means syntactically awesome style sheets is a preprocessor Similar preprocessors: LESS, Stylus (needs JS, i.e. a node.js server
  • 6. Installing Sass In order to install and run Sass, you need to have Ruby installed on your system. Mac OSX Easy! Ruby is built in :) Linux if not installed, use the package manager $ sudo apt-get install ruby1.9.1-full on Windows? use http://rubyinstaller.org/ to install ruby
  • 7. Installing Sass $ sudo gem install sass install beta version: $ sudo gem install sass --pre already installed Sass? check with $ sass --version
  • 8. Create your first Sass (SCSS) file create a sass folder create styles.scss open in your favourite editor* * Sublime Text 2
  • 9. Wait? What is the SCSS-thingy?
  • 10. Sass or SCSS? Sass has two syntaxes. The new main syntax is known as “SCSS” (for “Sassy CSS”). SCSS files use the extension .scss. The second, older syntax is known as the indented syntax (or just “Sass”). Instead of brackets and semicolons, it uses the indentation of lines to specify blocks. Files in the indented syntax use the extension .sass.
  • 11. SCSS section { margin: 1em 0; header { background-color: lightpink; } } Sass section margin: 1em 0 header background-color: lightpink
  • 12. compiling to CSS - watch changes open terminal $ sass input.scss output.css watch folder $ sass --watch sass:css watch file $ sass --watch sass/style.scss:css/style.css
  • 13. GUIs many GUIs for compiling · Livereload ($9.99) · Fire.App ($14) · Compass.app ($10) · CodeKit ($28) · Prepros ($19) · Scout App (free) and build in in many text editors or IDEs
  • 14. Compiling output styles :compressed // sass --watch sass:css --style compressed html,body{height:100%}.container{min-height:100%;max-width:1200px;width:auto;margin: :compact // sass --watch sass:css --style compact html, body { height: 100%; } .container { min-height: 100%; max-width: 1200px; width: auto; margin: 0 auto; padding .container h1 { border-bottom: 2px solid black; color: #ff8700; margin: 0 0 0.5em; }
  • 15. Compiling output styles :nested // sass --watch sass:css --style nested html, body { height: 100%; } .container { min-height: 100%; max-width: 1200px; width: auto; margin: 0 auto; padding: 0 20px; } .container h1 { border-bottom: 2px solid black; color: #ff8700; margin: 0 0 0.5em; }
  • 16. Compiling output styles :expanded // sass --watch sass:css --style expanded html, body { height: 100%; } .container { min-height: 100%; max-width: 1200px; width: auto; margin: 0 auto; padding: 0 20px; } .container h1 { border-bottom: 2px solid black; color: #ff8700; margin: 0 0 0.5em; }
  • 17. Compiling output with line numbers :line-numbers // sass --watch sass:css --style expanded --line-numbers ... /* line 12, ../sass/style.scss */ .container { min-height: 100%; max-width: 1200px; width: auto; margin: 0 auto; padding: 0 20px; } /* line 19, ../sass/style.scss */ .container h1 { border-bottom: 2px solid black; color: #ff8700; margin: 0 0 0.5em; }
  • 18. Debugging in Sass 3.3 Sourcemaps to work with original files in developer tools scss --sourcemap sass/styles.scss public/styles.css Include in Sass: /*# sourceMappingURL=styles.css.map */ Sassmaps output { "version": "3", "mappings": "4DAUA,qFAWQ,CACJ,OAAO,CAAE,KAAK,CAOlB,…", "sources": ["../sass/_vars.css”,”../sass/styles.scss"], "file": "styles.css" }
  • 20. working with variables h1 { border-bottom: 2px solid #000000; // black color: #FF8700; // orange margin: 0 0 0.5em; } SCSS change to global variables $brand-color1: #000000; $brand-color2: #FF8700; h1 { border-bottom: 2px solid $brand-color1; color: $brand-color2; margin: 0 0 0.5em; } SCSS
  • 21. Variables variables can be colors, sizes, percentage, ... $page_max_width: 1200px; $padding: 20px; SCSS .container { min-height: 100%; max-width: $page_max_width; width: auto; margin: 0 auto; padding: 0 $padding; } SCSS
  • 22. Calculating with Sass SCSS .container { max-width: $page_max_width - $padding * 2; padding: 0 $padding; ... } CSS .container { max-width: 1160px; /* 1200px - 20px * 2 */ padding: 0 20px; ... } SCSS
  • 24. Nesting writing long selectors is time consuming short selectors are better in general CSS nav nav nav nav nav {float: right;} li {float: left;} li a {color: #666;} li a:hover {color: #333;} li.current {font-weight: bold;}
  • 25. Nesting SCSS nav { float: right; li { float: left; a { color: #666; &:hover { color: #333; } } &.current { font-weight: bold; } } } SCSS
  • 26. Nesting identation with SCSS makes no difference in CSS output SCSS nav {float: right; li {float: left; a {color: #666; &:hover { color: #333;} } &.current { font-weight: bold;} }} but sure it looks better if intended SCSS
  • 27. Nesting HOW DEEP CAN I GO? Sass nesting != HTML nesting be careful with nesting! you can run into performance issues with long selectors
  • 29. Combining Selectors div { color: black .foo { color: black } // + .foo { color: black } // // > .foo { color: black } // ~ .foo { color: black } // // & .foo { color: black } // // &.bar { color: black } &:hover { color: black } } SCSS descendant adjacent sibling child general sibling Sass' parent selector div { color: black; } div .foo { color: black; } div + .foo { color: black; } div > .foo { color: black; } div ~ .foo { color: black; } div .foo { color: black; } div.bar { color: black; } div:hover { color: black; }
  • 30. Parent Selector - the ampersand the & (ampersand) has a placeholder function for the parental selector div { .foo { color: black } &.foo { color: black } } div .foo { color: black } div.foo { color: black; } SCSS
  • 31. Parent Selector - the ampersand a { &:hover, &:focus { color: black } } a:hover, a:focus { color: black; } SCSS
  • 32. Parent Selector - the ampersand Usecase for Modernizr classes div { box-shadow: 0 0 5px rgba(#000, 0.8); // Sass feature for Hex to RGB colors .no-boxshadow & { border: 1px solid #555; } } div { box-shadow: 0 0 5px rgba(#000, 0.8); } .no-boxshadow div { border: 1px solid #555; } SCSS
  • 33. Parent Selector - the ampersand div { .parent & .child { color: black } } .parent div .child { color: black; } SCSS
  • 34. Parent Selector - the ampersand @media queries in place aside { width: 100%; @media screen and (min-width: 680px) { width: 25%; } } aside { width: 100%; } @media screen and (min-width: 680px) { aside { width: 25%; } } SCSS
  • 35. BTW did you recognize the Comments? /* Hey look at this multiline comment * that we want to show up in our CSS output. */ .container { color: black; } // These comments are single lines and // we do not want them to appear in our CSS footer { color: #336699; } This compiles to: /* Hey look at this multiline comment * that we want to show up in our CSS output. */ .container { color: black; } footer { color: #336699; } SCSS
  • 37. Importing the way in CSS /* style.css */ @import "base.css"; @import url("styles.css"); @import url("druck.css") print; Importing CSS files into one file can cause performance issues Limit your external references in your HTML Importing in Sass is better split your stylesheet in many chunks and use the import function of Sass
  • 38. Importing @import "modules/base"; @import "partials/header", "partials/footer"; SCSS create subfolders and devide into partials use underscore in your filenames to concatinate the partials within the compiling process
  • 39. Importing Imagine this structure /style.sass /modules/ ┗ _normalize.sass ┗ _base.sass ┗ _mixins.sass /partials/ ┗ _footer.sass ┗ _header.sass /ie.sass /print.sass none underscore files will be compiled into seperate CSS files
  • 40. Importing # style.sass @import modules/normalize @import modules/base @import modules/mixins @import partials/header @import partials/footer @import ie @import print this compiles to 3 files: /css ┗ style.css ┗ ie.css ┗ print.css SCSS
  • 42. @extend @extend clones the attributes from rules and adds them to another rule. .button { background-color: $color-main; font-weight: bold; color: white; padding: 5px; } SCSS Then we can @extend the class to another .button-checkout { @extend .button; background-color: darken($color-main, 20%); } SCSS
  • 43. @extend .button-checkout { @extend .button; background-color: darken($color-main, 20%); .msg & { @extend .button; background-color: darken($color-main, 30%); } } .button, .button-checkout, .msg .button-checkout { background-color: blue; font-weight: bold; color: white; padding: 5px; } .button-checkout { background-color: #000099; } .msg .button-checkout { background-color: #000066; } SCSS
  • 44. Placeholder Selectors: %foo // This ruleset won't be rendered on its own. %button { color: blue; font-weight: bold; font-size: 2em; } SCSS placeholder selectors can be extended, just like classes and IDs. The extended selectors will be generated, but the base placeholder selector will not .btn-notice { @extend %button; } .btn-notice { color: blue; font-weight: bold; font-size: 2em; } SCSS
  • 45. %placeholder placeholder selectors will not be rendered to CSS. %button { background-color: $color-main; font-weight: bold; color: white; padding: 5px; } .button-checkout { @extend %button; background-color: darken($color-main, 20%); } .button-checkout { background-color: #000099; font-weight: bold; color: white; padding: 5px; } SCSS
  • 46. @mixin Man, tell me the cool things!
  • 47. Mixins Are code snippets (reusable elements) Parameterizable (use reasonable defaults) @mixin border-radius($value) { -webkit-border-radius: $value; -moz-border-radius: $value; border-radius: $value; } .box { color: $color-main; font-family: $helvetica-font-stack; @include border-radius(5px); } SCSS
  • 48. Mixins compiled to .box { color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } but thats a bad example – no need for the vendor prefixes of borderradius anymore only use border-radius: 5px; in your stylesheets
  • 49. Mixins Defaults and named arguments @mixin link-colors($text:blue, $hover:red) { color: $text; &:hover { color: $hover; } } a { @include link-colors($hover: green); } a { color: blue; } a:hover { color: green; } SCSS
  • 50. Mixins SCSS @mixin my-btn($color) { color: $color; } @include my-btn(red); SCSS Sass =my-btn($color) color: $color +my-btn(red) SCSS
  • 51. Using @content @mixin ie6 { * html & { @content; } } .m-login { float: right; @include ie6 { display: inline; } } .m-login { float: right; } * html .m-login { display: inline; } SCSS
  • 53. Functions Operators Relational operators (<, >, <=, >=) evaluate numbers 1 < 20 // true 10 <= 20 // true 4 > 1 // true 4 >= 1 // true SCSS Comparison operators (==, !=) evaluate all data types 1 + 1 == 2 // true small != big // true #000 == black // true SCSS
  • 54. Functions Control Directives @if @for @each @while $theme: ocean; div { @if $theme == dusty { background: #c6bba9; color: $color; } @else if $theme == ocean { background: blue; color: white; } } SCSS
  • 55. Functions @for loop @for $level from 0 to 5 { .tag-#{$level + 1} { font-size: .7em + ($level * .5em); } } .tag-1 .tag-2 .tag-3 .tag-4 .tag-5 { { { { { font-size: font-size: font-size: font-size: font-size: 0.7em; 1.2em; 1.7em; 2.2em; 2.7em; } } } } } SCSS
  • 56. Functions User Functions @function grid-width($cells) { @return ($cell-width + $cell-padding) * $cells; } SCSS Function to calculate the em font size from pixels @function px2em($font_size, $base_font_size: 16) { @return $font_size / $base_font_size + em } SCSS
  • 58. Variables in queries use main breakpoints as variables $break-small: 320px; $break-large: 1200px; .profile-pic { float: left; width: 100px; @media screen and (min-width: $break-small) { width: 250px; float: none; } @media screen and (min-width: $break-large) { float: right; } } Responsive Web Design in Sass: Using Media Queries in Sass 3.2 SCSS
  • 59. Mixin for different media queries using @content SCSS $break-small: 320px; $break-large: 1200px; @mixin respond-to($media) { @if $media == smartpones { @media only screen and (max-width: @content; } } @else if $media == tablet { @media only screen and (min-width: and (max-width: @content; } } @else if $media == desktop { @media only screen and (min-width: @content; } } } $break-small) { $break-small + 1) $break-large - 1) { $break-large) {
  • 60. Mixin for different media queries using @content Usage // profile picture module .profile-pic { float: left; width: 250px; @include respond-to(smartpones) { width: 100% ;} @include respond-to(tablet) { width: 125px; } @include respond-to(desktop) { float: none; } } SCSS
  • 61. Mixin for different media queries using @content CSS output sample .profile-pic { float: left; width: 250px; } @media only screen and (max-width: 320px) { .profile-pic { width: 100%; } } @media only screen and (min-width: 321px) and (max-width: 1199px) { .profile-pic { width: 125px; } } @media only screen and (min-width: 1200px) { .profile-pic { float: none; } }
  • 63. Sass-IE Writing mobile-first styles without leaving IE < 9 behind Media Query Mixin: // all.scss $fix-mqs: false !default; @mixin respond-min($width) { // If we're outputting for a fixed media query set... @if $fix-mqs { // ...and if we should apply these rules... @if $fix-mqs >= $width { // ...output the content the user gave us. @content; } } @else { // Otherwise, output it using a regular media query @media screen and (min-width: $width) { @content; } } } // and a respond-max mixin, that does what you might expect Sass-IE
  • 64. Sass-IE OldIE Mixin: // all.scss $old-ie: false !default; @mixin old-ie { // Only use this content if we're dealing with old IE @if $old-ie { @content; } } Separate IE stylesheet // all-old-oldie.scss $old-ie: true; $fix-mqs: 65em; @import 'all';
  • 65. Including the Sass-IE CSS To give the CSS to the browsers, use good old conditional comments: <!--[if lte IE 8]> <link rel="stylesheet" href="css/all-old-ie.css"> <![endif]--> <!--[if gt IE 8]><!--> <link rel="stylesheet" href="css/all.css"> <!--<![endif]-->
  • 67. Compass Compass is to Sass like jQuery to Javascript Compass is a Framework, that extends Sass It brings a lot of CSS3 mixins and useful CSS stuff http://sonspring.com/journal/sass-for-designers
  • 68. Compass Plugins Github List of Compass Plugins loading Compass plugins add to the config.rb # config.rb ... require 'compassplugin' @import 'compassplugin'; SCSS
  • 69. RGBAPNG Plugin Compass plugin for providing cross-browser compatible RGBA support by creating transparent PNGs on the fly for browsers that don't support RGBA. https://github.com/aaronrussell/compass-rgbapng $ sudo gem install compass-rgbapng @import "rgbapng"; .box { @include rgba-background(rgba(0,0,0,0.75)); } .box { background: url('/images/rgbapng/000000bf.png?1282127952'); background: rgba(0, 0, 0, 0.75); } SCSS
  • 70. Compass plugins Responsive Grid Plugin – Susy $ sudo gem install compass-susy-plugin $ compass create myproject -r susy -u susy Add Susy plugin to existing projects # config.rb require "susy"
  • 71. Susy Usage SCSS @import "susy"; // global variables $total-columns: 12; $column-width: 4em; $gutter-width: 1em; $grid-padding: $gutter-width; // // // // // usage .page { @include container; @include susy-grid-background; } a 12-column grid each column is 4em wide 1em gutters between columns grid-padding equal to gutters
  • 72. Susy Usage .page { // page acts as a container for our grid. @include container; // header and footer are full-width by default. header, footer { clear: both; } // nav spans 3 columns of total 12. nav { @include span-columns(3,12); } .content { // content spans the final (omega) 9 columns of 12. @include span-columns(9 omega,12); // main content spans 6 of those 9 columns. .main { @include span-columns(6,9); } // secondary content spans the final 3 (omega) of 9 columns. .secondary { @include span-columns(3 omega,9); } } }
  • 73. Compass plugins Responsive Grid Plugin – Singularity – Grids without limits $ sudo gem install singularitygs $ compass create myproject -r singularitygs --using singularitygs Add Singularity plugin to existing projects # config.rb require "singularitygs" @import 'singularitygs';
  • 74. Symmetric Grids - Twitter Bootstrap $grids: 12; $gutters: 1/3; Responsive Grids by @snugug
  • 75. Symmetric Grids - Zurb Foundation $grids: 12; $gutters: 0.9375em; $gutter-style: split; Responsive Grids by @snugug
  • 76. Asymetric Grids with Singularity $grids: 1 4 1; $gutters: 1/6; $gutter-style: split; Responsive Grids by @snugug
  • 77. Singularity Usage @include grid-span($span, $location); SCSS // Span 1 column, starting at the 2nd column .span1-pos2 { @include grid-span(1, 2); } // Span 3 columns, starting at the 3th column .span3-pos3 { @include grid-span(3, 3); } // Span 5 columns, starting at the 7th column .span5-pos7 { @include grid-span(5, 7); }
  • 78. Easy 12 column grid $grids: 12; $gutters: 12px; $gutter-styles: 'split' 'fixed'; $output: 'float'; @for $i from 1 through $grids { .grid#{$i} { @include grid-span($i); } } Easy 12 column grid
  • 79. Compass plugins simple media queries Sass plugin – Breakpoint $ gem install breakpoint Add plugin to projects # config.rb require "breakpoint" // main.scss @import "breakpoint"; SCSS
  • 80. Breakpoint plugin usage // basic media queries, min-width and min/max width $basic: 543px; $pair: 456px 794px; .foo { content: 'No Media Queries'; @include breakpoint($basic) { content: 'Basic Media Query'; } @include breakpoint($pair) { content: 'Paired Media Query'; } } SCSS
  • 81. Breakpoint plugin CSS output /* Nested Breakpoint calls become separate media queries */ .foo { content: 'No Media Queries'; } @media (min-width: 543px) { .foo { content: 'Basic Media Query'; } } @media (min-width: 456px) and (max-width: 794px) { .foo { content: 'Paired Media Query'; } }
  • 82. Breakpoint Media Types $breakpoint-to-ems: true; $media: 'screen' 700px; #foo { @include breakpoint($media) { content: 'Media'; } } @media screen and (min-width: 43.75em) { #foo { content: 'Media'; } } SCSS
  • 83. Team Sass on Github lot of Sass goodies · Singularity · Breakpoint · Toolkit · … https://github.com/Team-Sass
  • 84. Questions? Thanks for your attention! Sven Wolfermann | maddesigns http://maddesigns.de/rwd-sass-compass/ HTML5 slideshow by Google