Coder Social home page Coder Social logo

intro_to_sass's Introduction

Intro to Sass

Using Sass (scss) to build a basic Style Guide

Installing Sass

Install Ruby ๐Ÿ’Ž on your computer: brew install ruby (Windows users will need to install Ruby from an installer online). To globally install Sass on your computer, run gem install sass.

Watching a File

We can watch our Sass files so they are automatically converted to usuable CSS. To do so, we run the following command in the same folder as our SCSS files:

sass -w your_file.scss or sass --watch your_file.scss:compiled_css_file.css Where we say sass please listen for changes in your_file.scss and output the changes to *compiled_css_file.css

Variables

To create and re-use variables:

$my_variable: 0px;
$my_other_variable: black;

body {
  font-size: $my_variable;
  color: $my_other_variable;
}

Importing other SCSS files

We can import other SCSS files for code organization!

variables.scss

$my_variable: 0px;
$my_other_variable: black;

style.scss

@import 'variables.scss';

body {
  font-size: $my_variable;
  color: $my_other_variable;
}

Comments

// sass allows us to use JS style comments... these won't be compiled into the CSS file

Style Guide & Font Example

Rule of Thumb for Style Guides

Note that every style guide is unique. This is just a good starting point.

  • Headline Text: 300%
    • B-Head (sub) text: 150%
    • Nav Item: 100%
    • Body copy (text): 100% - starting point could be body { font-size: 16px }
  • Byline: 75%

Examples with Sass variables

  • 1rem = 100%
  • rem is responsive and related to the root of the page.
// style guide variables

$headline-text: 3rem; // 300%
$body-text: 1rem;   // 100%
$nav-item: 1.25rem; // 125%
$sub-header: 1.50rem; // 150%
$byline: 0.75rem; // 75%

body {
  font-size: 16px;
}

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.