More Related Content Similar to 3 Steps to Make Better & Faster Frontends (20) 3 Steps to Make Better & Faster Frontends2. SCSS > DRY CSS
Compass > Simple CCS3
Lemonade > Easy Sprites
5. Color Calculations
h1 {
background:
lighten($my-color, 23%);
color:
darken(#c24, 10%);
border-color:
desaturate(red, 50%);
}
6. Color Functions
★ opacify(color, amount)
★ transparentize(color, amount)
★ lighten(color, amount)
★ darken(color, amount)
★ saturate(color, amount)
★ desaturate(color, amount)
★ adjust-hue(color, degrees)
★ mix(color1, color2, weight)
★ grayscale(color)
★ complement(color)
7. RGBA Colors
h2 {
background: rgba(#00f, 0.7);
}
R, G, B
#hex
colorconst
$variables
12. Extending
.box {
background: red;
}
.bordered-box {
border: 1px black solid;
@extend .box;
}
16. More to Learn
★ Include partials
(no asset packer needed)
★ Auto compress CSS files
★ @if, @for, @while syntax
★ “&” as current cascading placeholder
17. SCSS > DRY CSS
Compass > Simple CCS3
Lemonade > Easy Sprites
20. Helpers
h1 {
@include ellipsis;
@include clearfix;
}
a {
@include hover-link;
}
22. More to Learn
★ Easy to extend with your own gem
★ Use other frameworks
(960gs, suzy, YUI, YAML, jqTouch, …)
★ Write own frameworks
23. SCSS > DRY CSS
Compass > Simple CCS3
Lemonade > Easy Sprites
25. Simple Sprites
.add {
background:
sprite-image("icons/pl.png");
}
.remove {
background:
sprite-image("icons/rm.png");
}
all icons by p.yusukekamiyamane.com (CC by 3.0)
26. Output
.add {
background:
url("icons.png");
}
.remove {
background:
url("icons.png") 0 -16px;
}
27. Right Aligned
.something {
background:
sprite-image("i/wide.png");
}
a.next {
background: yellow no-repeat
sprite-image("i/n.png", 100%);
padding-right: 20px;
}
28. Result
.something {
background:
url("i.png");
}
Example link
a.next {
background: yellow no-repeat
url("i.png") 100% -20px;
padding-right: 20px;
}
29. Empty Space
.add {
background:
sprite-image("icons/pl.png");
}
.remove {
background: yellow no-repeat
sprite-image("icons/rm.png");
padding: 20px;
}
30. Could be Better
.add {
background:
url("icons.png");
}
.remove { Example link
background:
url("icons.png") 0 -16px;
padding: 20px;
}
31. Empty Space
.add {
background:
sprite-image("icons/pl.png");
}
.remove {
background: yellow no-repeat
sprite-image("icons/rm.png",
0, 0, 20px);
padding: 20px; }
32. Just Perfect
.add {
background:
url("icons.png");
}
.remove { Example link
background:
url("icons.png") 0 -36px;
padding: 20px;
}
33. Sprite Generation
★ Sprite image named by directory:
“icons/*.png” > “icons.png”
★ Background position added only if needed
★ Add “no-repeat” by yourself:
background:
sprite-image("…") no-repeat;