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.8k
Accessibility By Design
laurakalbag
1
97
Designing For Accessibility
laurakalbag
2
140
Indie Design
laurakalbag
4
1.8k
WAI-ARIA in 10
laurakalbag
1
230
Designing for Accessibility
laurakalbag
0
69
Designing for Accessibility
laurakalbag
1
500
Other Decks in Design
See All in Design
root COMPANY DECK / We are hiring!
root_recruit
1
15k
超・ファシリテーション 無理ゲー課題を軽やかに超える MIMIGURI流チームデザイン|TOKYO CREATIVE COLLECTION
madue
1
1.2k
AIと創る広告の未来 ― タップルと極AIお台場スタジオの最新事例― / ai-tapple-odaiba
cyberagentdevelopers
PRO
1
350
エムスリー株式会社 デザイングループ紹介資料 / m3design-team-profile
m3designer
0
4.7k
みんなに知って欲しい 視覚過敏のアクセシビリティ
0opacity_
4
830
ZOZO CDO Office Design
zozodevelopers
PRO
1
440
【Designship 2024|10.13】デザイン組織を進化させるための仕組み化の要諦
payatsusan213
1
550
Managing Design Systems (Smashing NY 2024)
nathanacurtis
2
300
新しいemoji😄のアイデアをUnicodeが募集中‼️🏃♀️💨💨💨傾向を学んでみんな提案しよう💪
oguemon
2
690
20240921-図書館の実空間とデジタル資源の接点をデザインする-dtk55-Designing-the-interface-between-the-library's-physical-space-and-digital-resources
majimasachi
0
310
プロダクトデザイナー視点から見た チームでの意思決定の難しさと 重要ポイント3点
kei141
0
420
我做了一個詐騙網站...嗎?
crboy
1
150
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
For a Future-Friendly Web
brad_frost
175
9.4k
Thoughts on Productivity
jonyablonski
67
4.3k
The Language of Interfaces
destraynor
154
24k
Producing Creativity
orderedlist
PRO
341
39k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Rails Girls Zürich Keynote
gr2m
94
13k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Designing the Hi-DPI Web
ddemaree
280
34k
Making Projects Easy
brettharned
115
5.9k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
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 :)