SlideShare a Scribd company logo
AUGMENTING
STYLESHEETS
Introduction to CSS processors
Tristan Ashley | @tawashley
WHO AM I?
➤ Front End Developer at Code Computerlove
➤ Been doing things on the web and front ends for 4+ years
➤ @tawashley
ERM, WHAT?
SUBTLETY CHANGING THE
WAY YOU WRITE AND
MANAGE STYLESHEETS TO
MAKE YOUR LIFE EASIER
HELP SUPER CHARGE
YOUR CSS
TYPES OF PROCESSORS
➤ Pre-processors
➤ Post-processors
WHY USE THEM?
BENEFITS OF USING PROCESSORS
➤ Helps reduce development time.
➤ Helps produce DRYer code.
➤ Add a heap of features to style authoring
➤ Engrained user base / ecosystems
McrFRED 39 | CSS Processors
PRE-PROCESSORS
Compile to CSS
PRE-PROCESSORS
FEATURE TICK OFF LIST
➤ Real @imports - file partials
➤ Simple reference of parent selector &.
➤ Variables.
➤ Built-in and custom functions.
➤ mixins
➤ Many more
McrFRED 39 | CSS Processors
@IMPORTS - CSS
@import('component1.css');
@import('component2.css');
@import('component3.css');
@import('component4.css');
@IMPORTS - SASS
@import('component1');
@import('component2');
@import('component3');
@import('component4');
VARIABLES
$c-primary: red;
$c-secondary: #f00;
$d-columns: 10;
$d-gutter: 12px;
$isRtl: true;
$d-gutter--double: $d-gutter*2;
VARIABLES CONT.
http://www.sassmeister.com/gist/7b15f388f34d3e8c69aaa10c2f6a0c74
$c-primary: red;
$d-gutter: 24px;
$d-gutter--double: $d-gutter*2;
body {
background: $c-primary;
}
.box-1 {
width: $d-gutter;
height: $d-gutter;
background: $c-primary;
}
VARIABLES CONT.
http://www.sassmeister.com/gist/7b15f388f34d3e8c69aaa10c2f6a0c74
$c-primary: red;
$d-gutter: 24px;
$d-gutter--double: $d-gutter*2;
body {
background: $c-primary;
}
.box-1 {
width: $d-gutter;
height: $d-gutter;
background: $c-primary;
}
VARIABLES CONT.
http://www.sassmeister.com/gist/7b15f388f34d3e8c69aaa10c2f6a0c74
$c-primary: red;
$d-gutter: 24px;
$d-gutter--double: $d-gutter*2;
body {
background: $c-primary;
}
.box-1 {
width: $d-gutter;
height: $d-gutter;
background: $c-primary;
}
body {
background: red;
}
.box-1 {
width: 24px;
height: 24px;
background: red;
}
VARIABLES INTERPOLATION
$alignment: left;
.flow-#{$alignment} {
position: absolute;
text-align: $alignment;
#{$alignment}: 0;
}
.flow-left {
position: absolute;
text-align: left;
left: 0;
}
PARENT SELECTOR
http://www.sassmeister.com/gist/0017308d572929833b2d8465afdc035e
.button {
background: red;
&:hover {
background: yellow;
}
&:before {
position: absolute;
background: black;
content: '';
width: 100%;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
}
.button {
background: red;
}
.button:hover {
background: yellow;
}
.button:before {
position: absolute;
background: black;
content: '';
width: 100%;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
NESTING SELECTORS
.block {
font-size: 20px;
color: white;
&__element {
float: left;
width: 50%;
}
&--inverse {
color: black;
}
}
.block {
font-size: 20px;
color: white;
}
.block__element {
float: left;
width: 50%;
}
.block--inverse {
color: black;
}
NESTING SELECTORS CONT.
header {
nav {
li {
display: inline-block;
a {
background: white;
color: black;
}
}
}
}
header nav li {
display: inline-block;
}
header nav li a {
background: white;
color: black;
}
MIXINS
http://www.sassmeister.com/gist/adf4f9de4d923400572f00581bc8abb7
@mixin button-style($radius: 20px) {
border-radius: $radius;
@include text-ellipsis;
}
@mixin text-ellipsis($width: 200px) {
width: $width;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.button {
@include button-style;
}
.button--extra-rounded {
@include button-style($radius: 35%);
}
MIXINS
http://www.sassmeister.com/gist/adf4f9de4d923400572f00581bc8abb7
@mixin button-style($radius: 20px) {
border-radius: $radius;
@include text-ellipsis;
}
@mixin text-ellipsis($width: 200px) {
width: $width;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.button {
@include button-style;
}
.button--extra-rounded {
@include button-style($radius: 35%);
}
.button {
border-radius: 20px;
width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.button--extra-rounded {
border-radius: 35%;
width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
MIXINS CONT.
http://www.sassmeister.com/gist/adf4f9de4d923400572f00581bc8abb7
@mixin on-active {
&:hover,
&:active,
&:focus {
@content;
}
}
a {
background: black;
@include on-active {
background: white;
}
}
a {
background: black;
}
a:hover, a:active, a:focus {
background: white;
}
CUSTOM FUNCTIONS
http://www.sassmeister.com/gist/549afe8db08f61d31ef3e54ca0debe51
$d-btn-width: 100px;
$d-btn-height: 20px;
@function double($number) {
@return $number*2
}
.button {
width: double($d-btn-width);
height: $d-btn-height;
}
.button {
width: 200px;
height: 20px;
}
BUILT-IN FUNCTIONS
http://www.sassmeister.com/gist/5d03451a05ed13715806caefd248b529
sass-lang.com/documentation/Sass/Script/Functions.html
$c-primary: #f00;
.button {
background: $c-primary;
&:hover {
background: darken($c-primary, 20%);
}
&:active {
background: lighten($c-primary, 20%);
}
}
.button {
background: #f00;
}
.button:hover {
background: #990000;
}
.button:active {
background: #ff6666;
}
WELL, THIS ALL LOOKS
SWELL!
BUT...HOW DO I USE
SASS TODAY?
HOW YOU CAN USE SASS TODAY
➤ Install Ruby - http://rubyinstaller.org/
➤ Open command line program
➤ Run 'gem install sass'
➤ If this errors, instead run 'sudo gem install sass'
➤ After this, you're all ready to go!
GETTING ALL SASSY
RESOURCES
➤ http://www.sassmeister.com/
➤ Sass Playground
➤ https://sass-guidelin.es/
➤ Opinionated guide to using Sass
➤ http://hugogiraudel.com/
POST-PROCESSORS
Manipulate CSS files themselves
McrFRED 39 | CSS Processors
POST-PROCESSORS
➤ Help fill in the gap of Pre-processors.
➤ Can be used with a pre-processor
➤ Or...can do things a pre-processor can do.
➤ Healthy plugin ecosystem.
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
WELL, THIS ALL LOOKS
SWELL! (AGAIN)
BUT...HOW DO I USE
POSTCSS TODAY?
McrFRED 39 | CSS Processors
JAVASCRIPT API
var postcss = require('postcss');
postcss([ require('autoprefixer'), require('cssnano') ])
.process(css, { from: 'src/app.css', to: 'app.css' })
.then(function (result) {
fs.writeFileSync('app.css', result.css);
if ( result.map ) fs.writeFileSync('app.css.map', result.map);
});
GULP API
gulp.task('css', function () {
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
return gulp.src('src/**/*.css')
.pipe( sourcemaps.init() )
.pipe( postcss([ require('autoprefixer'), require('precss') ]) )
.pipe( sourcemaps.write('.') )
.pipe( gulp.dest('build/') );
});
THANKS
Any questions?

More Related Content

What's hot (20)

ODP
Introduction To Less
Knoldus Inc.
 
PPS
Creating a-pagination-with-php
Rakhitha Ratnayake
 
PDF
JSON and the APInauts
Wynn Netherland
 
PDF
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Adam Darowski
 
PDF
CSS3 Refresher
Ivano Malavolta
 
PDF
Finding your way with Sass+Compass
drywallbmb
 
PPTX
Patrick Kettner - Creating magic with houdini
OdessaJS Conf
 
PPTX
Sass
Prabhakaran R
 
PDF
Class 4 handout two column layout w mobile web design
Erin M. Kidwell
 
KEY
FCIP SASS Talk
Chris Schneider
 
PPTX
Software programming tools for creating/managing CSS files
Dinu Suman
 
PDF
Class 3 create an absolute layout with css abs position (aptana)
Erin M. Kidwell
 
PPTX
AAVN_Presentation_SASS.pptx
Hoàng Nguyễn Mạnh
 
PDF
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
bentleyhoke
 
PDF
Sass Essentials
romiguelangel
 
PDF
PHP and Rich Internet Applications
elliando dias
 
PDF
Erik mogensen stowe
Erik Mogensen
 
PDF
Newfangeldy Front End Stuff For People Who Last Touched It Back When Grunge W...
Angela Byron
 
RTF
dfhdf
guest635119
 
PDF
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
 
Introduction To Less
Knoldus Inc.
 
Creating a-pagination-with-php
Rakhitha Ratnayake
 
JSON and the APInauts
Wynn Netherland
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Adam Darowski
 
CSS3 Refresher
Ivano Malavolta
 
Finding your way with Sass+Compass
drywallbmb
 
Patrick Kettner - Creating magic with houdini
OdessaJS Conf
 
Class 4 handout two column layout w mobile web design
Erin M. Kidwell
 
FCIP SASS Talk
Chris Schneider
 
Software programming tools for creating/managing CSS files
Dinu Suman
 
Class 3 create an absolute layout with css abs position (aptana)
Erin M. Kidwell
 
AAVN_Presentation_SASS.pptx
Hoàng Nguyễn Mạnh
 
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
bentleyhoke
 
Sass Essentials
romiguelangel
 
PHP and Rich Internet Applications
elliando dias
 
Erik mogensen stowe
Erik Mogensen
 
Newfangeldy Front End Stuff For People Who Last Touched It Back When Grunge W...
Angela Byron
 
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
 

Similar to McrFRED 39 | CSS Processors (20)

PDF
Workshop 6: Designer tools
Visual Engineering
 
PDF
SASS, Compass, Gulp, Greensock
Marco Pinheiro
 
PDF
Sass & Compass (Barcamp Stuttgart 2012)
emrox
 
PPTX
Managing responsive websites with css preprocessors.
The University of Akron
 
PPTX
Supercharged HTML & CSS
Max Kraszewski
 
PDF
Assembling Sass
Hossain Mohammad Samrat
 
PDF
Preprocessor presentation
Mario Noble
 
PDF
Class 2: CSS Selectors, Classes & Ids
Erika Tarte
 
PDF
Theming and Sass
James Pearce
 
PPTX
CSS: A Slippery Slope to the Backend
FITC
 
PDF
Css
actacademy
 
DOCX
Css
actacademy
 
PDF
Front-End Dev Tools
Netguru
 
PDF
CSS 開發加速指南-Sass & Compass
Lucien Lee
 
PDF
Rapid Prototyping
Even Wu
 
PDF
Work and play with SASS & Compass
Andreas Dantz
 
PPTX
Css frameworks
Dimitar Belchugov
 
PDF
LESS : The dynamic stylesheet language
Katsunori Tanaka
 
PPTX
SASS is more than LESS
Itai Koren
 
Workshop 6: Designer tools
Visual Engineering
 
SASS, Compass, Gulp, Greensock
Marco Pinheiro
 
Sass & Compass (Barcamp Stuttgart 2012)
emrox
 
Managing responsive websites with css preprocessors.
The University of Akron
 
Supercharged HTML & CSS
Max Kraszewski
 
Assembling Sass
Hossain Mohammad Samrat
 
Preprocessor presentation
Mario Noble
 
Class 2: CSS Selectors, Classes & Ids
Erika Tarte
 
Theming and Sass
James Pearce
 
CSS: A Slippery Slope to the Backend
FITC
 
Front-End Dev Tools
Netguru
 
CSS 開發加速指南-Sass & Compass
Lucien Lee
 
Rapid Prototyping
Even Wu
 
Work and play with SASS & Compass
Andreas Dantz
 
Css frameworks
Dimitar Belchugov
 
LESS : The dynamic stylesheet language
Katsunori Tanaka
 
SASS is more than LESS
Itai Koren
 
Ad

Recently uploaded (20)

PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Practical Applications of AI in Local Government
OnBoard
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Ad

McrFRED 39 | CSS Processors