Web Developer

SASS Section 2 – Variables

declare variable: start with ‘$’

Different kinds of variable declaration:

  • normal: $width : 600px; $float: 1.5; $int: 20;
  • Strings:
    • $string : ‘../images/hello.jpg’;
    • $stringTwo : “../images/hello.jpg”;
    • $stringThree : no-repeat; //without quotation marker
    • $stringSelector : element; //can treat as selector
      • to use as tag selector: #{$stringSelector}
      • to use as ID selector: ##{$stringSelector}
      • to use as class selector: .#{$stringSelector}
  • Colors:
    • $colString : gray;
    • $hex : #ccc;
    • $rgb : rgb(230,230,230);
    • $rgba : rgba(230,230,230,.2);
  • Lists:
    • $list : 1px 1px 3px black, 3px 3px 4px #ccc;
  • Others:
    • $map: ( “key1”: “value1”, “color”: blue );
    • $bool: true; //Boolean type
    • $null: null; //null value