2. What is Sass?
• CSS preprocessor written in Ruby
• Compiles to regular CSS
• Adds many helpful features to CSS…
Official Documentation:
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html
3. What is Compass?
• An extension of Sass
• Contains many CSS3 helpers used in
modern web development.
• Adds many helpful features to CSS…
Official Documentation:
http://compass-style.org/reference/compass/
12. Adding Specificity with Nested
Rules
SCSS CSS output
ul { ul {
list-style-type: disc; list-style-type: disc;
li { }
padding:10px; ul li {
} padding: 10px;
} }
13. Ampersands in Nested Rules
When nested rules are used, an
ampersand adds properties to a child
selector and is useful for pseudo classes
like :hover.
14. Ampersands in Nested Rules
SCSS CSS output
a { a {
text-decoration:none; text-decoration: none;
&:hover { }
text-decoration:underline; a:hover {
} text-decoration: underline;
} }
15. Ampersands in Nested Rules
(cont’d)
SCSS CSS output
p { p {
font-size:14px; font-size: 14px;
&.error { }
color:#f00; p.error {
font-weight:bold; color: #f00;
} font-weight: bold;
} }
16. Did you catch the difference?
Notice there is no space between p and
.error in the CSS from the previous
example.
17. If you WANTED a space…
SCSS CSS output
p { p {
font-size:14px; font-size: 14px;
.error { }
color:#f00; p .error {
font-weight:bold; color: #f00;
} font-weight: bold;
} }
18. Multiple Nesting
You don’t have to stop at one level of
nesting. Multiple levels of nesting can be
VERY powerful.
23. Tips for using @import
• Put common properties in external file
• Different than using @import in CSS
• Imported files should begin with an “_”
24. @import
SCSS CSS output
// Loads Compass CSS3 helpers /*
@import 'compass/css3'; Loads all helpers from Compass’
CSS3 modules and makes it
// Loads user defined files available to the rest of our
project.
@import 'base';
@import 'reset';
Imports the “_base.scss” file
and then imports the
“_reset.scss” file .
*/
25. @mixin
• Small piece of code that is used to build
something larger
• Define once and use anywhere
• Can accept arguments and parameters
• Used via the @include keyword