Optimize existing CSS
Deadly sins
Optimize existing CSS
Optimize existing CSS
Optimize existing CSS
Optimize existing CSS
Selectors
Optimize existing CSS
Selectors
div ul li .special
Optimize existing CSS
Selectors
div ul li .special
1
Optimize existing CSS
Selectors
div ul li .special
1
2
Optimize existing CSS
Selectors
div ul li .special
1
2
3
Optimize existing CSS
Selectors
1
2
3
4
div ul li .special
Optimize existing CSS
Clean up unused CSS
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Optimize images
Optimize existing CSS
Reset CSS
Optimize existing CSS
Vendor specific rules
Optimize existing CSS
Best practices
Optimize existing CSS
Best practices
.foo {
color: red;
font-size: 24;
padding: 10;
}
.bar {
color: blue;
font-size: 24;
padding: 10;
}
.foo, .bar {
font-size: 24;
padding: 10;
}
.foo {
color: red;
}
.bar {
color: blue;
}
How to CSS in 2015
Preprocessors to the rescue!
Preprocessors to the rescue!
Which one?
Preprocessors to the rescue!
Which one?
Sass
Less
Preprocessors to the rescue!
Variables
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
Preprocessors to the rescue!
Variables
$font-size-xl: 40px;
h1 {
font-size: $font-size-xl + 5;
}
h1 {
font-size: 45px;
}
Preprocessors to the rescue!
Nesting
nav {
color: #000;
ul {
list-style: none;
}
}
nav {
color: #000;
}
nav ul {
list-style: none;
}
Preprocessors to the rescue!
Nesting
nav {
color: #000;
ul {
list-style: none;
}
}
nav {
color: #000;
}
nav ul {
list-style: none;
}
Preprocessors to the rescue!
Nesting
.slider {
width: 100%;
&-element {
width: 25%;
}
}
.slider {
width: 100%;
}
.slider .slider-element {
width: 25%;
}
Preprocessors to the rescue!
Nesting
.button {
color: $color-primary;
&:hover {
color: $color-highlight;
}
}
.button {
color: #bada55;
}
.button:hover {
color: #c0ffee;
}
Preprocessors to the rescue!
Nesting
Preprocessors to the rescue!
Partials, Imports
_partial.scss
@import 'partial'
nav {
color: #000;
}
Preprocessors to the rescue!
Partials, Imports
Preprocessors to the rescue!
Mixins
@mixin box() {
display: inline-block;
padding: 5px;
box-sizing: border-box;
}
.button {
@include box();
background-color: #bada55;
}
.button {
display: inline-block;
padding: 5px;
box-sizing: border-box;
background-color: #bada55;
}
Preprocessors to the rescue!
Mixins
@mixin box($radius) {
display: inline-block;
padding: 5px;
box-sizing: border-box;
border-radius: $radius;
}
.button {
@include box(10px);
background-color: #bada55;
}
.button {
display: inline-block;
padding: 5px;
box-sizing: border-box;
border-radius: 10px;
background-color: #bada55;
}
Preprocessors to the rescue!
Extend/Inheritance
.message {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
@extend .message;
border-color: green;
}
.success {
border: 1px solid #ccc;
padding: 10px;
color: #333;
border-color: green;
}
Preprocessors to the rescue!
Functions
Preprocessors to the rescue!
Control directives
Preprocessors to the rescue!
Control directives
Preprocessors to the rescue!
How to compile it?
Preprocessors to the rescue!
Wrapping up
How to CSS in 2015
Media queries and their friends
How to CSS in 2015
Media queries and their friends
.box {
width: 200px;
}
@media(max-width: 480px) {
.box {
width: 100%;
}
}
How to CSS in 2015
Media queries and their friends
@media(max-width: $screen-xs)
and (min-width: $screen-lg) {
.box {
width: 100%;
}
}
How to CSS in 2015
Media queries and their friends
$desktop: "(min-width: 1024px)";
@media #{$desktop} {
.box {
width: 100%;
}
}
How to CSS in 2015
Media queries and their friends
$desktop-width: 1024px;
@mixin desktop {
@media (min-width: #{$desktop-width}) {
@content;
}
}
p {
font-size: 16px;
@include desktop {
font-size: 20px;
}
}
How to CSS in 2015
Wrapping up
the future is bright
flexbox
SVG animations
How to CSS in 2015
Wrapping up
How to CSS in 2015
Wrapping up