Managing responsive websites with css preprocessors presented at Penn State Webconference Tuesday June 23, 2015. Sass and Less preprocessors simplify managing css for responsive websites.
10. Compiling SASS
From command line:
sass style.scss - prints to screen
sass style.scss ../css/style.css – prints to file
sass –-watch style.scss ../css/style.css – watches file for changes
with compass: compass watch – watches entire scss directory
uses a config.rb file for configuration of where to save file changes
12. Basics of Sass
Mixins
Similar sets of properties used
multiple times with small
variations
Extend
Sets of properties that
match exactly
Functions
Commonly used operations
to determine value
Variables
$basesize: 12px;
$primary-color: #00285e;
Nesting
Sass adds the ability to nest
selectors in ways you can't
do in css
Built in Functions
Sass provides it's own set of
functions
darken($primary-color, 10%)
19. When to use
Mixins
Similar sets of properties used
multiple times with small
variations
Extend
Sets of properties that
match exactly
Functions
Commonly used operations
to determine value
20. Operators
Mixins
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder
Equality
== Equal to
!= Not equal to
String
font: Arial + " sans-serif";
Comparison
and x and y true if both x and y are true
or x or y true if either x or y is true
not x true if x is not true
21. Compass http://compass-style.org/
@import 'compass';
@import 'compass/reset';
html {
@include box-sizing;
}
body {
font-size: 100%;
}
compiled css
.. reset stuff
html {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-size: 100%;
}
25. Let's code – Vinyl vintage website
David Bowie Grateful DeadFocus
Genesis Talking HeadsTodd
Rundgren
Logo
26. Sass/Compass productivity
• Sass and Compass team up for maximum productivity and help you accomplish browser
compatibility
• Susy allows you to create your own grid layouts
• Bootstrap or Foundation are more complete css frameworks that help you style large sites
with lots of configurations
• SassMeister.com allows you to play with sass and evaluate frameworks that will best suit your
application
Foundation sass: http://foundation.zurb.com/docs/sass.html
Bootstrap sass: http://getbootstrap.com/getting-started/#download
27. Less
• Less is javascript based, so requires node.js and npm to install and run
• Less.js can be a client side processor for times you want runtime generation of css
• Less syntax is not very different from Sass. The main issue is using @ for variables instead of $
28. Tools for the "No command line" types
• Codekit (mac): https://incident57.com/codekit/index.html
• Cactus (mac): http://cactusformac.com/
• Mixture: http://mixture.io/
• Webstorm: https://www.jetbrains.com/webstorm/
• Scout: http://mhs.github.io/scout-app/
• Prepos: https://prepros.io/
29. Resources and contact info
• bradrice.com/blog
• Sass resources – http://www.bradrice.com/sass-resources
• Less resources - http://www.bradrice.com/less-resources
• Github repo - https://github.com/bradrice/vinyl
• Github repo for webstart - https://github.com/bradrice/webstart
• Twitter: @brad_rice
• Email: brad@bradrice.com
Notas do Editor
The viewport dilemma. Standard mobile web devices have different widths and heights.
----- Meeting Notes (5/5/15 10:17) -----
The meta viewport allows for mobile web browsers to display in their native device width.
----- Meeting Notes (5/5/15 10:17) -----
The previous University of Akron web template used multiple css.
Using SASS with imports this is reduced to 3 files.
All three are similar. I usually start with mixins and eventually extend or function will reveal itself to me as a better option along the way.
Use nesting to namespace for template changes.
image replacement placeholder for insterting css image in an element
https://gist.github.com/bradrice/8384673a125b747aa91e
All three are similar. I usually start with mixins and eventually extend or function will reveal itself to me as a better option along the way.
Operators for sass for use in mixins and functions