Giter VIP home page Giter VIP logo

sass-basic-cheatsheet's Introduction

sass-basic-cheatsheet

Super basic reference for sass basics

neat video tutorial reference: https://www.youtube.com/watch?v=_a5j7KoflTs

use .scss

various setup configs required to make sass feel good

  • dont forget to follow tutorial to replicate config

variables

$var: val;

maps

$map: ( "a": 1, "b": 2 );
map-get($map, a);

nesting css classes

  • requires interpolation

parent: 'main' child: 'main__paragraph'

.main {
    #{&}__paragraph {
    }
}

partials files that can be included in other sass files (reuse css)

named _file.scss (underscore prefix)

can be imported into other scss files by prepending destination file with @import path;

functions and mixins function example:

@function foo($arg) {
    @return $arg;
}

mixin example 1:

@mixin foo($arg) {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: $arg;
}

.main {
    @include foo(column);
}

mixin example 2:

$mobile: 800px;

@mixin mobile {
    @media (max-width: $mobile) {
        @content
    }
}

.main {
    @include mobile {
       display: flex;
       flex-direction: column; 
   }
}

extensions extend the styles of one component to another (in the same context)

.main {
    width: 100%;
    margin: 0 auto;

    #{&}__paragraph1 {
        ...
    }

	#{&}__paragraph2 {
		@extend .main__paragraph1
		...
	}
}

operations sass does not rely on calc(...)

operations can be done raw: width: 80% - 40%;

note that this does not support non-matched types, i.e. width: 80% - 400px; is an invalid operation, and calc must still be used in this case

sass-basic-cheatsheet's People

Contributors

alexliu245 avatar

Watchers

James Cloos avatar  avatar

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.