2. www.tothenew.com
Agenda
● SASS installation
● What is Sass?
● Why Would we use Sass?
● Difference b/w Sass and Scss
● Variables In Sass
● Math in Sass
● Functions
● Nesting
● Imports
● Partials
● Extends & placeholders
● Mixins
● Function
● Difference between Functions & Mixins
3. www.tothenew.com
Installation
For Practice we will use:- Sassmeister
1. Download the Ruby installer: http://rubyinstaller.org/downloads/
1. In cmd run command :
gem install sass
1. Go to folder in which your scss folder exists and open cmd run command:
sass --watch scss:css
4. www.tothenew.com
What is SASS
Sass (Syntactically Awesome Style Sheets)
SASS is a CSS Preprocessor.
Sass adds a feature set to your stylesheet markup that makes writing styles fun again.
CSS stylesheets are getting larger, more complex, and harder to maintain.
This is where a preprocessor can help.
Sass lets you use features that don't exist in CSS yet, like
1. Variables
2. Nesting
3. Mixins
4. Function
5. www.tothenew.com
Why would we use Sass?
● Easily Maintainable
● More Done in Less Code
● More Readable in Less Time
● More Features like :-
1. Variables
2. Math
3. Functions
4. Nesting
5. Imports
6. Extends & Placeholders
7. Mixins
8. Function
6. www.tothenew.com
Difference b/w Sass and Scss
SASS vs SCSS
SASS : When Sass first came out, the main syntax was noticeably different from CSS. It used
indentation instead of braces, didn't require semicolons and had shorthand operators.
SCSS : In version 3 Sass changed it's main syntax to .scss.
SCSS is a superset of CSS, and is basically written the exact same, but with all the fun new Sass
features.
8. www.tothenew.com
Variables in SASS
Variables allow you to assign a value to an easy-to-remember placeholder name.
Works with hex values, strings of text, colors, numbers, boolean values, or even value lists
In Short--
No more memorizing hex values :)
Example :--
https://www.sassmeister.com/gist/646f359c2e503ec5020f61ef562acfb2
9. www.tothenew.com
Math in SASS
Unlike CSS, Sass allows us to use mathematical
expressions! This is super helpful within mixins,
and allows us to do some really cool things with
our markup.
14. www.tothenew.com
Partials
If you prefix a .sass or .scss file with an underscore, it will not get compiled to
CSS. This is helpful if your file only exists to get imported into a master
style.scss and not explicitly compiled.
_partial.scss.
@import _partial.scss.
17. www.tothenew.com
Mixins
It allows you to include styles the same way @extend would, but with the ability to supply and
interpret arguments.
SASS
CSS
18. www.tothenew.com
Function
A function looks a lot like a mixin, and they both accept the same types of arguments. Although they
look similar,a Sass function behaves differently. While a mixin makes our life easier by lessening
typing repetitive code, a function allows you to strip repeatable logic from your code.
20. www.tothenew.com
Adding fonts in SASS
Adding fonts from from local:
@font-face {
font-family: 'Calibri';
src: url('../fonts/Calibri.eot');
src: url('../fonts/Calibri.eot?#iefix') format('embedded-opentype'),
url('../fonts/Calibri.woff') format('woff'),
url('../fonts/Calibri.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Adding Google Fonts:-
Just add link of your google fonts in top of your scss file.