Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sass for designers
Search
Laura Kalbag
July 25, 2013
Design
12
3k
Sass for designers
From a talk at CSS Summit in July 2013
Laura Kalbag
July 25, 2013
Tweet
Share
More Decks by Laura Kalbag
See All by Laura Kalbag
Ethical Design
laurakalbag
1
110
Intro to UX
laurakalbag
1
160
Ethical Design
laurakalbag
1
2.9k
Accessibility By Design
laurakalbag
1
97
Designing For Accessibility
laurakalbag
2
140
Indie Design
laurakalbag
4
1.9k
WAI-ARIA in 10
laurakalbag
1
230
Designing for Accessibility
laurakalbag
0
70
Designing for Accessibility
laurakalbag
1
500
Other Decks in Design
See All in Design
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
180
東急URBAN HACKSのデザイナーって何やってるの? 〜Designer Night #1〜 移動・不動産領域の取り組み
tmtgtkhs
0
160
地図・デザイン・可視化 −情報をわかりやすく伝えるために−
hjmkth
2
530
Personal Story Sequence - Vendetta(WIP)
elrns88
0
340
開発チームの中心で心理的安全性をつくる、UXデザイナーの問いかけ方
takuto_yonemichi
2
610
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
180
LayerX DesignersDeck
layerx
PRO
0
920
ネーミングの極意 - その名は体を現していますか? -
kakukoki
2
400
FANCL×CA流アプリリニューアルPJ 成功の秘訣とそのプロセス / dx-fancl-renewal
cyberagentdevelopers
PRO
2
480
Haruki_Konaka_Portforio.pdf
haruki556
0
780
202409_会社概要資料_Englishver.pdf
zakkerooni
0
210
Figma Code Connect を使ってエンジニアの新しい体験をデリバリする
junkifurukawa
0
450
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Documentation Writing (for coders)
carmenintech
66
4.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Practical Orchestrator
shlominoach
186
10k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Transcript
Slide Sass for designers @laurakalbag Sass for designers 1
Slide Sass for designers @laurakalbag 2 HTML and CSS loads
JavaScript a tiny bit Programming argh! scary! Illustration fairly often Print design every now and again Web design loads What I do
Slide Sass for designers @laurakalbag 3 Documentation for LESS and
Sass LESS Sass
Slide Sass for designers @laurakalbag 4 the command line intimidates
me
Slide Sass for designers @laurakalbag 5 this talk will show
you some of the basic features of Sass
Slide Sass for designers @laurakalbag Setting up a project using
Sass 6
Slide Sass for designers @laurakalbag You can re-trace my steps
later on GitHub 7 https://github.com/laurakalbag/webtalkdogwalk
Slide Sass for designers @laurakalbag 8 Use CodeKit for Sass
: http://incident57.com/codekit/
Slide Sass for designers @laurakalbag 9 http://alphapixels.com/prepros/ http://mixture.io/ CodeKit alternatives
for Windows
Slide Sass for designers @laurakalbag 10 Download CodeKit at http://incident57.com/codekit/
Slide Sass for designers @laurakalbag 11 Unzip the CodeKit folder
and drag it into Applications
Slide Sass for designers @laurakalbag 12 Open up CodeKit
Slide Sass for designers @laurakalbag 13 web talk dog walk
my web talk dog walk idea
Slide Sass for designers @laurakalbag 14 Mockups in Sketch (http://www.bohemiancoding.com/sketch/)
Slide Sass for designers @laurakalbag 15 Sublime Text 2 (http://www.sublimetext.com/2)
my (current) preferred text editor
Slide Sass for designers @laurakalbag 16 HTML/PHP in Sublime Text
2 HTML all set up and ready to style
Slide Sass for designers @laurakalbag 17 HTML as seen in
Google Chrome
Slide Sass for designers @laurakalbag 18 File > Add Project…
choose the project folder add the project to CodeKit
Slide Sass for designers @laurakalbag 19 the project as seen
in CodeKit
Slide Sass for designers @laurakalbag 20 Hold shift to select
multiple files and then click ‘Hide These Files’ hide the files we don’t want to compile or compress
Slide Sass for designers @laurakalbag 21 when the files are
hidden, you don’t see them (!)
Slide Sass for designers @laurakalbag 22 Create an empty folder
called ‘sass’ in the site’s root folder set up a folder for the Sass files
Slide Sass for designers @laurakalbag 23 Create an empty file
in the ‘sass’ folder and call it ‘style.scss’ our first Sass file (.scss)
Slide Sass for designers @laurakalbag 24 Use the Package Manager
to install Syntax Highlighting for Sass add syntax highlighting so Sass is easy to read
Slide Sass for designers @laurakalbag The difference between .sass and
.scss 25
Slide Sass for designers @laurakalbag .sass and .scss are both
Sass syntaxes 26
Slide Sass for designers @laurakalbag 27 .scss .sass no semi-colons
; and no curly brackets {} semi-colons ; and curly brackets {} the differences between .scss and .sass
Slide Sass for designers @laurakalbag .scss allows ordinary CSS to
be used in the same files 28 and this is why I use it
Slide Sass for designers @laurakalbag First steps in Sass 29
Slide Sass for designers @laurakalbag 30 my CSS reset in
the style.scss file
Slide Sass for designers @laurakalbag 31 Hit the refresh icon
on the bottom left to see the style.scss file our first .scss file in CodeKit
Slide Sass for designers @laurakalbag 32 compile the Sass file
using CodeKit select the style.scss file and click ‘Compile’
Slide Sass for designers @laurakalbag 33 the CSS folder CodeKit
has created you can see where CodeKit created the folder and file
Slide Sass for designers @laurakalbag 34 style.css, as generated by
CodeKit from the style.scss file the CSS CodeKit has created
Slide Sass for designers @laurakalbag 35 Select ‘Compressed’ from the
Output Style: dropdown compress the outputted CSS to make it nice and quick
Slide Sass for designers @laurakalbag 36 Select ‘Compressed’ from the
Output Style: dropdown when CodeKit compiles, it has a progress bar and notification
Slide Sass for designers @laurakalbag 37 style.css, created, compiled and
compressed by CodeKit
Slide Sass for designers @laurakalbag 38 Link to the compiled
and compressed CSS file
Slide Sass for designers @laurakalbag 39 the CSS reset in
action
Slide Sass for designers @laurakalbag Partials 40
Slide Sass for designers @laurakalbag 41 a messy file
Slide Sass for designers @laurakalbag 42 Jonathan Snook’s SMACSS http://smacss.com/book/categorizing
a sensible way to split up files
Slide Sass for designers @laurakalbag 43 @import “reset”; Sass partial
syntax include this in the compiled version of this file the file name
Slide Sass for designers @laurakalbag 44 Use @import to tell
CodeKit to compile all these files into style.css
Slide Sass for designers @laurakalbag 45 see how CodeKit doesn’t
compile partials directly Save the files so CodeKit compiles them
Slide Sass for designers @laurakalbag 46 See that CodeKit hasn’t
created any more files
Slide Sass for designers @laurakalbag Variables 47
Slide Sass for designers @laurakalbag 48 mockup colour palette
Slide Sass for designers @laurakalbag 49 $grey-light: #f9f9f9; Sass variable
syntax name of the variable the variable unit
Slide Sass for designers @laurakalbag 50
Slide Sass for designers @laurakalbag Comments 51
Slide Sass for designers @laurakalbag 52 /* this comment will
show in the CSS */ // this comment will only show in the Sass Sass comment syntax
Slide Sass for designers @laurakalbag 53 Add a Sass-only comment
to the top of the file
Slide Sass for designers @laurakalbag 54 colour variables on my
base elements
Slide Sass for designers @laurakalbag 55 the CodeKit Log and
error Syntax error: undefined variable: "$grey-dark";
Slide Sass for designers @laurakalbag 56 the variables partial wasn’t
being imported, this caused the error
Slide Sass for designers @laurakalbag 57 the site is starting
to look more like the mockup
Slide Sass for designers @laurakalbag Vertical rhythm with variables 58
Slide Sass for designers @laurakalbag 59 I’ve added web fonts
to the site but it lacks visual hierarchy
Slide Sass for designers @laurakalbag 60 the base grid I’ve
used on my mockup
Slide Sass for designers @laurakalbag 61 a variable based on
my mockup grid base unit
Slide Sass for designers @laurakalbag 62 the body text font
size in the mockup is 15px
Slide Sass for designers @laurakalbag 63 Sass variable operations syntax
font-size: $unit*1.5; property a number name of the variable multiply by
Slide Sass for designers @laurakalbag 64 Make the body text
the size of the base unit multiplied by 1.5
Slide Sass for designers @laurakalbag 65 Save the file and
see how Sass compiles the variable into 15px
Slide Sass for designers @laurakalbag 66 Use the base unit
on all elements to achieve basic vertical rhythm
Slide Sass for designers @laurakalbag 67 Now the hierarchy is
clearer, but the font size is too small
Slide Sass for designers @laurakalbag 68 Change the variable unit
to affect all instances of $unit bump up the unit size by 1px
Slide Sass for designers @laurakalbag 69 Now the text is
more readable
Slide Sass for designers @laurakalbag 70 I’ve added more colour,
illustrations and padding to the site
Slide Sass for designers @laurakalbag Mixins 71
Slide Sass for designers @laurakalbag 72 the web talk dog
walk title appears twice on the page
Slide Sass for designers @laurakalbag 73 In a headers.scss partial,
write the rules to hide the first title
Slide Sass for designers @laurakalbag 74 add a new partial
called mixins.scss
Slide Sass for designers @laurakalbag 75 Sass mixin syntax for
defining a mixin @mixin hide { height: 0; margin: 0; overflow: hidden; padding: 0; } create a mixin mixin rules mixin name
Slide Sass for designers @laurakalbag 76 Create a mixin called
“hide”
Slide Sass for designers @laurakalbag 77 Sass mixin syntax for
including a mixin .site-title { @include hide; } include a mixin selector mixin name
Slide Sass for designers @laurakalbag 78 Include the “hide” mixin
rules for the site title
Slide Sass for designers @laurakalbag 79 Now the site title
is hidden and I can reuse that rule elsewhere
Slide Sass for designers @laurakalbag Nesting 80
Slide Sass for designers @laurakalbag 81 The navigation buttons have
the class .site-navigation
Slide Sass for designers @laurakalbag 82 In CSS, I would
lay out the rules for the navigation by specificity
Slide Sass for designers @laurakalbag 83 Sometimes I’d indent the
CSS to make it easier to read
Slide Sass for designers @laurakalbag 84 Nest the rules inside
the parent to make it easy to read
Slide Sass for designers @laurakalbag 85 It just works in
the same way as ordinary CSS
Slide Sass for designers @laurakalbag 86 I want to make
the selected navigation item stand out use & to use a classname selector while nesting
Slide Sass for designers @laurakalbag 87 Now the .selected class
is styled differently
Slide Sass for designers @laurakalbag 88 Use & to include
pseudo selectors
Slide Sass for designers @laurakalbag 89 Now the :hover works
Slide Sass for designers @laurakalbag Nesting media queries 90
Slide Sass for designers @laurakalbag 91 some kind of vertical
rhythm no kind of vertical rhythm I need to fix the text in the header. It doesn’t line up.
Slide Sass for designers @laurakalbag 92 How I’d use media
queries in ordinary CSS
Slide Sass for designers @laurakalbag 93 With Sass, we can
nest the media query inside the selector
Slide Sass for designers @laurakalbag 94 We can use the
unit variable in the media queries our breakpoints are now relative to our base unit
More mixins Slide Sass for designers @laurakalbag 95
Slide Sass for designers @laurakalbag 96 The line length is
too long, the layout feels stretched out
Slide Sass for designers @laurakalbag 97 Use max-width and margin:
auto to centre multiple elements
Slide Sass for designers @laurakalbag 98 The repetition makes this
suitable for making into another mixin
Slide Sass for designers @laurakalbag 99 Use this centre-layout mixin
to make my stylesheet cleaner
Slide Sass for designers @laurakalbag 100 The layout now looks
more like the mockup
Slide Sass for designers @laurakalbag 101 Floating responsive containers with
borders is tricky
Slide Sass for designers @laurakalbag 102 Solve the problem with
borders using box-sizing: border-box;
Slide Sass for designers @laurakalbag 103 box-sizing: border-box; needs backup
with prefixes moz and webkit need prefixes to make border-box work
Slide Sass for designers @laurakalbag 104 Another repetitive chunk of
code that makes a great mixin
Slide Sass for designers @laurakalbag 105 Now the boxes have
borders and float nicely
Parent selectors Slide Sass for designers @laurakalbag 106
Slide Sass for designers @laurakalbag 107 PNGs don’t work so
well on zoom or hi-DPI displays
Slide Sass for designers @laurakalbag 108 .png .svg Use SVGs
with a clever script to detect SVG support the .svg version of the file looks crisp at any size
Slide Sass for designers @laurakalbag 109 Use the .svg class
to show an SVG version of the image the script adds ‘svg’ as a body class when SVG is supported
Slide Sass for designers @laurakalbag 110 This is how I
would use the .svg class without a parent selector
Slide Sass for designers @laurakalbag 111 Sass syntax for parent
selectors .svg & { background: url(‘../images/bone.svg’) 0 0 no-repeat; } properties parent selector
Slide Sass for designers @laurakalbag 112 Use the parent selector
to include the SVG background
Slide Sass for designers @laurakalbag 113 Now the bullet points
look crisp
Slide Sass for designers @laurakalbag Colour operations 114
Slide Sass for designers @laurakalbag 115 I want the H2
titles to be a brighter green
Slide Sass for designers @laurakalbag 116 our base file where
I specify the H2 colour
Slide Sass for designers @laurakalbag 117 Sass syntax for saturating
colour color: saturate($green-dark, 100%); colour operation property variable name amount of saturation
Slide Sass for designers @laurakalbag 118 At 100% saturation, the
green looks much brighter previous saturation level 100% saturation
Slide Sass for designers @laurakalbag 119 the final site: http://webtalkdogwalk.in/brighton
Slide Sass for designers @laurakalbag 120 Thank you! Catch me
on app.net or Twitter, I’m @laurakalbag :)