🦁_21.11.24(2) TIL

BoriΒ·2021λ…„ 11μ›” 25일
0
post-thumbnail

21λ…„ 11μ›” 24일(2)

πŸ“ Sass

Sass: Syntactically Awesome Style Sheets

  • Sass/SCSSλ₯Ό μ“°λŠ” 이유
    • μŠ€νƒ€μΌ μ‹œνŠΈκ°€ 점점 더 컀지고 λ³΅μž‘ν•΄μ§€λ©΄μ„œ μœ μ§€λ³΄μˆ˜κ°€ 어렀움
    • Sass μ•ˆμ— μžˆλŠ” λ³€μˆ˜, λ„€μ΄μŠ€νŒ…, 믹슀인, κ°€μ Έμ˜€κΈ°, 상속, λ‚΄μž₯κΈ°λŠ₯ λ“± CSS에 μ—†λŠ” 편의 κΈ°λŠ₯듀을 톡해 μ‹œκ°„ μ ˆμ•½
    • μ½”λ“œ μž¬μ‚¬μš©μ„± 용이

πŸ“Ž Sass

  • Sass λŠ” CSS둜 컴파일 λ˜λŠ” μŠ€νƒ€μΌ μ‹œνŠΈ ν™•μž₯ 언어이며, CSS μ „μ²˜λ¦¬κΈ°(CSS pre-processor)의 ν•˜λ‚˜
  • λΈŒλΌμš°μ €κ°€ Sassλ₯Ό 직접 λ‘œλ”©ν•˜λŠ” 것이 μ•„λ‹ˆλΌ Sassλ₯Ό 기반으둜 κ°œλ°œν•œ ν›„, CSS둜 exportν•˜λŠ” 과정을 κ±°μΉ¨
    => λΈŒλΌμš°μ €λŠ” Sass νŒŒμΌμ„ 직접 읽지 λͺ»ν•˜λ―€λ‘œ 일반 CSS둜 μ»΄νŒŒμΌν•˜λŠ” 과정이 ν•„μš”
    => μ‹€μ œ μ›Ή μ—…κ³„μ—μ„œ 많이 μ‚¬μš©ν•˜λŠ” μ „μ²˜λ¦¬κΈ°

Sass κΈ°μˆ λ°©μ‹

  • .sass κΈ°μˆ λ°©μ‹
    => μ„ νƒμžμ˜ μœ νš¨λ²”μœ„λ₯Ό λ“€μ—¬μ“°κΈ°λ‘œ ꡬ뢄
    => μ„Έλ―Έμ½œλ‘ ;을 μ‚¬μš©ν•˜μ§€ μ•ŠμŒ
$font-stack: Helvetica, sans-serif
$primary-color: #333

body
  font: 100% $font-stack
  color: $primary-color
  • .scss κΈ°μˆ λ°©μ‹
    => μ„ νƒμžμ˜ μœ νš¨λ²”μœ„λ₯Ό μ€‘κ΄„ν˜Έ{}둜 ꡬ뢄
$font-stack: Helvetica, sans-serif;
$primary-color: #333;

body {
  font: 100% $font-stack;
  color: $primary-color;
}  

Sass와 SCSS의 차이점

Sass의 3λ²„μ „μ—μ„œ μƒˆλ‘­κ²Œ λ“±μž₯ν•œ SCSSλŠ” CSS ꡬ문과 μ™„μ „νžˆ ν˜Έν™˜λ˜λ„λ‘ μƒˆλ‘œμš΄ ꡬ문을 λ„μž…ν•΄ λ§Œλ“  Sass의 λͺ¨λ“  κΈ°λŠ₯을 μ§€μ›ν•˜λŠ” CSS의 μƒμœ„μ§‘ν•©.
즉, SCSSλŠ” CSS와 거의 같은 λ¬Έλ²•μœΌλ‘œ SassκΈ°λŠ₯을 μ§€μ›ν•œλ‹€

πŸ“Ž ν™˜κ²½μ„€μ •

Sass πŸ‘‰ CSS 둜 컴파일 ν•˜λŠ” 방법

Sass(SCSS)λŠ” μ›Ήμ—μ„œ 직접 λ™μž‘ν•  수 μ—†κ³ , 웹은 기본적으둜 css 파일둜만 λ™μž‘ν•˜κΈ° λ•Œλ¬Έμ— 이 νŒŒμΌλ“€μ€ λ³„λ„λ‘œ 컴파일 ν•˜λŠ” 과정을 거쳐 CSS 파일둜 λ³€ν™˜ν•˜μ—¬ μ‚¬μš©
=> λ‹€μ–‘ν•œ λ°©λ²•μœΌλ‘œ 컴파일 κ°€λŠ₯

  • VSC의 Live Sass Compiler Extension을 μ‚¬μš©
  • VSC Extension이 μ•„λ‹Œ 터미널을 μ‚¬μš© 방법
    • npm을 μ„€μΉ˜ : node.jsλ₯Ό μ„€μΉ˜ν•˜λ©΄ npm도 μžλ™μœΌλ‘œ μ„€μΉ˜λ¨
      => ν™ˆνŽ˜μ΄μ§€(http://www.nodejs.org)μ—μ„œ LTS λ²„μ „μœΌλ‘œ λ‹€μš΄λ°›κΈ°
    • VSCμ—μ„œ 터미널(Ctrl + ` ) μ—΄κΈ°
    • npm -v : npm 버전이 좜λ ₯되면 μ„€μΉ˜λ˜μ–΄ μžˆμŒμ„ 의미
    • npm init -y : -yλ₯Ό μ¨μ„œ μ§ˆλ¬Έμ—†μ΄ κΈ°λ³Έ μ„ΈνŒ… 진행 (주의! 폴더λͺ…이 ν•œκΈ€μΈ 경우 μ—λŸ¬κ°€ λ°œμƒν•  수 μžˆλ‹€)

      => package.json 파일이 생성됨
    • npm i node-sass : node-sass μ„€μΉ˜

      => node_modules, package-lock.json 파일이 생성됨
      (주의! git commitν•  경우, 이 νŒŒμΌλ“€μ€ .gitignore 파일 μ•ˆμ— μž‘μ„±ν•˜μ—¬ commit 에 μ œμ™Έ μ‹œν‚€κΈ°)
    • package.json μ•ˆμ— "scripts" 뢀뢄에 컴파일 ν•  파일과 컴파일 될 파일λͺ… μž‘μ„±
      => Sassμ—κ²Œ λΉŒλ“œν•  파일과 CSSλ₯Ό 좜λ ₯ν•  μœ„μΉ˜λ₯Ό 지정해야 ν•œλ‹€.
      => ν„°λ―Έλ„μ—μ„œ μ‹€ν–‰ν•˜λ©΄ 단일 Sass 파일인 input.scssκ°€ λ°œμƒν•˜κ³  ν•΄λ‹Ή 파일이 output.css둜 컴파일 λœλ‹€.


      [ν•΄λ‹Ή μœ„μΉ˜μ— 컴파일 된 css파일이 μƒμ„±λ˜λ„λ‘ 지정]
    • npm run sass : SassνŒŒμΌμ„ CSS파일둜 컴파일 μ‹€ν–‰
    • Sass μ—…λ°μ΄νŠΈ ν•˜κΈ° : -options μ‚¬μš©
      => [μ˜΅μ…˜] 뢀뢄에 -w, -r 을 μΆ”κ°€
      -w, --watch 
      // Wahch a directory or file
      -r, -recursive
      // Recursively watch directories or files
    • -w : μ˜΅μ…˜μ΄ 없을 λ•Œ Sass νŒŒμΌμ„ μˆ˜μ •ν•  λ•Œλ§ˆλ‹€ 컴파일러λ₯Ό μ‹€ν–‰μ‹œμΌœμ•Όν•œλ‹€. -w μ˜΅μ…˜μ„ μΆ”κ°€ν•˜λ©΄ Sassκ°€ 꺼지지 μ•Šκ³  μ§€μ†μ μœΌλ‘œ Sass 파일의 변경사항을 κ°μ‹œν•˜λ©΄μ„œ μ €μž₯ν•  λ•Œλ§ˆλ‹€ μžλ™μœΌλ‘œ μ»΄νŒŒμΌμ„ ν•΄μ€€λ‹€.
    • -r : -w와 λΉ„μŠ·ν•˜λ‚˜ -w만 μΆ”κ°€ν–ˆμ„ 경우, 메인 파일만 κ°μ‹œν•˜κ³  κ·Έ μ™Έμ˜ νŒŒμΌλ“€μ€ κ°μ‹œν•˜μ§€ μ•ŠλŠ”λ‹€. -r을 μΆ”κ°€ν•  경우, 메인 νŒŒμΌμ— importν•œ λ‹€λ₯Έ νŒŒμΌλ„ ν•¨κ»˜ κ°μ‹œν•œλ‹€.

      참고 링크

      https://www.npmjs.com/package/node-sass

πŸ“Ž 파일 뢄리

ν”„λ‘œμ νŠΈλ₯Ό 진행할 λ•Œ νŒŒμΌμ„ λΆ„λ¦¬ν•˜μ—¬ μ½”λ“œ 관리

  • 각 ν”„λ ˆμž„ 별(_header.scss, _home.scss) CSSλ₯Ό 뢄리
  • _variable.scss, _mixin.scss 뢄리
  • 메인 파일인 style.scss에 λΆ„λ¦¬ν–ˆλ˜ νŒŒμΌλ“€μ„ @import
    => νŒŒμΌμ„ μŠ€νƒ€μΌ, κΈ°λŠ₯ 및 λ ˆμ΄μ•„μ›ƒ λ³„λ‘œ λΆ„λ¦¬ν•˜μ—¬ μ‚¬μš©ν•˜κΈ° λ•Œλ¬Έμ— μ½”λ“œ 관리가 μš©μ΄ν•˜λ‹€.
  • 파일λͺ… μ•žμ— 언더바(_)의 의미 : Scss 파일 이름 μ•žμ— 언더바(_)λ₯Ό 뢙인닀면, Sassμ—κ²Œ 이 파일이 메인 파일의 μΌλΆ€μž„μ„ μ•Œλ €μ€˜μ„œ ν•΄λ‹Ή νŒŒμΌμ€ CSS파일둜 컴파일 ν•˜μ§€ μ•Šκ³  λ‚΄λΆ€μ—μ„œ @import ν˜•νƒœλ‘œ μž‘λ™
    => Sassμ—μ„œ @importν•  λ•Œ, ν™•μž₯λͺ…을 μ œμ™Έν•˜κ³  파일λͺ…λ§Œ μ‚¬μš© κ°€λŠ₯
    => CSSμ—μ„œ @importν•  λ•ŒλŠ” 파일의 URL을 μž‘μ„±ν•΄μ•Όν•œλ‹€.

πŸ“Ž 주석

/* μ—¬λŸ¬μ€„ 주석인 μ΄λ ‡κ²Œ μž‘μ„±ν•©λ‹ˆλ‹€ */
// ν•œ 쀄 주석은 μ΄λ ‡κ²Œ μž‘μ„±ν•©λ‹ˆλ‹€.
// ν•œ 쀄 주석은 CSS둜 컴파일 되면 보이지 μ•ŠμŠ΅λ‹ˆλ‹€.

πŸ“Ž 쀑첩(Nesting)

  • 쀑첩을 μ‚¬μš©ν•˜λ©΄, HTML의 μ‹œκ°μ  계측 방식과 λ™μΌν•˜κ²Œ CSSλ₯Ό μ€‘μ²©ν•˜μ—¬ μž‘μ„±ν•  수 μžˆλ‹€.
    => CSS μ½”λ“œκ°€ ꡬ쑰화 λ˜μ–΄ 가독성이 높아지고 μœ μ§€ λ³΄μˆ˜ν•˜κΈ° νŽΈλ¦¬ν•΄μ§„λ‹€.
<nav> 
  <!--navμ•ˆμ— ul 쀑첩-->
  <ul> 
  <!--ulμ•ˆμ— μ„Έ 개의 liκ°€ 쀑첩-->
    <li>one</li>
    <li>two</li>
    <li>three</li>
    <li>four</li>
  </ul> 
</nav>
// Scss
// Scssμ—μ„œλ„ HTML처럼 κ³„μΈ΅κ΅¬μ‘°λ‘œ μŠ€νƒ€μΌμ„ μ μš©ν•  수 μžˆλ‹€.
// μ€‘μ²©μœΌλ‘œ λΆ€λͺ¨ μ„ νƒμžλ₯Ό ν•œ 번 μ‚¬μš©
nav {
  background : #C39BD3;
  padding : 10px;
  height: 50px;
  ul {
    display: flex;
    list-style : none;
    justify-content: flex-end;
    li {
      color: white;
      margin-right: 10px;
    } 
  }
}

/* CSS */
/* μœ„μ˜ Sass μ½”λ“œμ™€ 동일 */
nav {
  background : #C39BD3;
  padding : 10px;
  height: 50px;
}

nav ul {
  display: flex;
  list-style : none;
  justify-content: flex-end;
}

nav ul li {
  color: white;
  margin-right: 10px;
}

쀑첩을 μ‚¬μš©ν•˜λŠ” 이유

  • CSSλŠ” λΆ€λͺ¨μ—κ²Œ μƒμ†λœ μžμ‹ μš”μ†Œμ—κ²Œ μŠ€νƒ€μΌ 적용 μ‹œ μ΅œμƒμœ„ μ„ νƒμžλ₯Ό 반볡 μ„ μ–Έν•΄μ•Ό ν•œλ‹€.
  • 쀑첩을 μ‚¬μš©ν•  경우 μ΅œμƒμœ„ μ„ νƒμžλ₯Ό ν•œ 번만 μ„ μ–Έν•˜μ—¬λ„ μžμ‹ μ„ νƒμžμ—κ²Œ μŠ€νƒ€μΌμ„ μ μš©ν•  수 μžˆμ–΄ 반볡된 μ½”λ“œκ°€ 쀄어든닀.
  • ν•˜μžλ§Œ μ§€λ‚˜μΉœ 쀑첩은 ν”Όν•΄μ•Όν•œλ‹€. 깊이 μ€‘μ²©λ˜λ©΄ μ½”λ“œλ₯Ό λ³΄λŠ”κ²Œ λΆˆνŽΈν•˜κ³ , 컴파일 ν–ˆμ„ 경우 λΆˆν•„μš”ν•œ μ„ νƒμžλ₯Ό μ‚¬μš©ν•˜κ²Œ λœλ‹€.

πŸ“Ž 속성 Nesting

  • μ„ νƒμž 뿐만 μ•„λ‹ˆλΌ μŠ€νƒ€μΌ 속성에도 쀑첩할 수 μžˆλ‹€.
  • 속성을 쀑첩할 λ•Œ 콜둠(:)을 μ‚¬μš©
    => SassλŠ” 속성이 μ€‘μ²©λ˜μ—ˆμŒμ„ μΈμ§€ν•˜κ³  CSS μ†μ„±λ“€λ‘œ λ³€ν™˜
// Scss
.bg-nesting {
  background : {
    image: url("../img/bg-main.png");
    position: center center;
    repeat: no-repeat;
    size: auto 450px;
  }
}

/* CSS */
.bg-nesting {
  background-image: url("../img/bg-main.png");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: auto 450px;
}

πŸ“Ž Ampersand(&)

  • & ν‚€μ›Œλ“œλŠ” μƒμœ„μ— μžˆλŠ” λΆ€λͺ¨ μ„ νƒμžλ₯Ό 가리킴

& ν‚€μ›Œλ“œλ₯Ό μ΄μš©ν•΄ 가상 μš”μ†Œ, κ°€μƒν΄λž˜μŠ€ μ°Έμ‘°

// Scss
.box {
  // 가상 클래슀
  &:focus{};
  &:hover{};
  &:active{};
  &:first-child{};
  &:nth-child(2){};
  // 가상 μš”μ†Œ
  &::after{};
  &::before{};
}

// Scss μ˜ˆμ‹œ
ul {
  li {
    &:hover {
      background: #fff;
      color: #333;
    }
    &:last-child {
      margin-bottom: 20px;
    }
  }
}

/* CSS */
ul li:hover {
  background: #fff;
  color: #333;
}

ul li:last-child {
  margin-bottom: 20px;
}

곡톡 클래슀 λͺ…을 가진 μ„ νƒμž 쀑첩

// Sass 
.box {
  &-yellow{
    background-color: yellow; 
  }
  &-red{
    background-color: red; 
  }
  &-green{
    background-color: green; 
  }
}

/* CSS */
.box-yellow {
  background-color: yellow; 
}
.box-red {
  background-color: red; 
}
.box-green {
  background-color: green; 
}

πŸ“Ž @at-root

  • @at-root ν‚€μ›Œλ“œλ₯Ό μ‚¬μš©ν•˜λ©΄ μ€‘μ²©μ—μ„œ λ²—μ–΄λ‚  수 μžˆλ‹€.
    => μ€‘μ²©μ—μ„œ λ²—μ–΄λ‚˜κ³  싢은 μ„ νƒμž μ•žμ— @at-rootλ₯Ό μž‘μ„±
    => μ€‘μ²©λœ μ„ νƒμžμ—κ²Œλ§Œ μ‚¬μš© κ°€λŠ₯
// Scss
.article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  .article-content {
    font-size: 14px;
    opacity: 0.7;
    @at-root i {
      opacity: 0.5;
    }
  }
}

/* CSS */
.article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.article .article-content {
  font-size: 14px;
  opacity: 0.7;
}
/* 쀑첩을 λΉ μ Έλ‚˜μ˜΄! */
i { 
  opacity: 0.5;
}

πŸ“Ž λ³€μˆ˜(Variable)

CSSμ—μ„œ λ³€μˆ˜?

  • λ³€μˆ˜ μ„ μ–Έ
    = 값을 ν•˜λ‚˜ν•˜λ‚˜ κ³ μΉ  ν•„μš”κ°€ μ—†λ‹€.
    = μœ μ§€λ³΄μˆ˜, μž¬μ‚¬μš©μ„± 용이
  • 단, λ¬΄λΆ„λ³„ν•œ λ³€μˆ˜ μ„ μ–Έ 주의
  • λ³€μˆ˜ μ„ μ–Έμ˜ κΈ°μ€€
    • 값이 적어도 두 번 반볡
    • 기쑴의 값이 적어도 ν•œ λ²ˆμ€ μˆ˜μ •λ  κ°€λŠ₯성이 클 경우
  • μ ˆλŒ€ μˆ˜μ •λ  일이 μ—†κ±°λ‚˜ ν•œ κ΅°λ°μ—μ„œλ§Œ μ‚¬μš©λ˜λŠ” λ³€μˆ˜λ₯Ό μ„ μ–Έν•˜λŠ” 것은 아무 의미 μ—†λ‹€.

λ³€μˆ˜ μƒμ„±ν•˜κΈ°

  • $기호λ₯Ό μ‚¬μš©ν•˜μ—¬ μŠ€νƒ€μΌμ„ μ μš©ν•  값을 μ €μž₯
// $λ³€μˆ˜λͺ… : κ°’

$font-stack: Helvetica, sans-serif;
$primary-color: #333;

body {
  font: 100% $font-stack;
  color: $primary-color;
}

λ³€μˆ˜ type

  • Numbers : λ‹¨μœ„λ₯Ό ν¬ν•¨ν•˜κ±°λ‚˜ ν¬ν•¨ν•˜μ§€ μ•Šμ„ 수 μžˆλ‹€.
    => 12, 100px
  • Strings : λ”°μ˜΄ν‘œλ₯Ό ν¬ν•¨ν•˜κ±°λ‚˜ ν¬ν•¨ν•˜μ§€ μ•Šμ„ 수 μžˆλ‹€.
    => "Helvetica Neue", bold
  • Colors : 일반적인 red, green κ³Ό 같은 μƒ‰μƒμ΄λ‚˜ #f0f0f0 λ“±μ˜ Hex ν‘œν˜„μœΌλ‘œλ„ μž‘μ„±ν•  수 μžˆλ‹€.
    => rgb(107, 113, 127), hsl(210, 100%, 20%).
  • Lists : μ‰Όν‘œλ‚˜ 곡백으둜 List λ₯Ό κ΅¬λΆ„ν•˜μ—¬ μž‘μ„±ν•œλ‹€.
    => Helvetica, Arial, sans-serif
    => 10px 15px 0 0
  • Boolean : true, false
  • Null : μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ nullκ³Ό λ§ˆμ°¬κ°€μ§€λ‘œ 아무것도 μ—†λŠ” 값을 λ‚˜νƒ€λ‚Έλ‹€.
  • Maps : 객체와 μœ μ‚¬ν•˜κ²Œ keyκ°’κ³Ό value 값을 μž‘μ„±ν•œλ‹€.
    => ("background" : red, "border-color" : blue)
  • Function : Sassμ—μ„œ μ œκ³΅ν•˜λŠ” λ‚΄μž₯ν•¨μˆ˜μ™€ μž„μ˜λ‘œ μž‘μ„±ν•  수 μžˆλŠ” ν•¨μˆ˜κ°€ μžˆλ‹€. (@function)
    => μ°Έκ³  - Sass Functions

λ³€μˆ˜ type - Lists

  • μˆœμ„œκ°€ μžˆλŠ” κ°’μœΌλ‘œ κ°’λ§ˆλ‹€ 인덱슀λ₯Ό 가짐
  • lists μš”μ†Œμ˜ ꡬ뢄 : μ‰Όν‘œ(,), 곡백( ), μŠ¬λž˜μ‹œ(/)둜 일관성 있게 ꡬ뢄
    => λ‹€λ₯Έ λ³€μˆ˜λ“€κ³Ό λ‹€λ₯΄κ²Œ 특수 κ΄„ν˜Έλ₯Ό μ‚¬μš©ν•˜μ§€ μ•Šμ•„λ„ lists둜 인식
    => 빈 lists λ˜λŠ” lists의 값이 ν•˜λ‚˜μΈ 경우, []λ‚˜ ()λ₯Ό μ‚¬μš©
  • lists의 μΈλ±μŠ€λŠ” 1λΆ€ν„° μ‹œμž‘
    (0λΆ€ν„° μ‹œμž‘ν•˜μ§€ μ•ŠμŒ)
$sizes: 40px, 50px, 80px;
$valid-sides: top, bottom, left, right;
  • lists κ΄€λ ¨ λ‚΄μž₯ ν•¨μˆ˜
    • append($list, $value) : lists에 값을 μΆ”κ°€
    • index($list, $value) : lists의 값에 λŒ€ν•œ 인덱슀 리턴
    • nth($list, n) : lists의 μΈλ±μŠ€μ— ν•΄λ‹Ήν•˜λŠ” 값을 리턴
// append
@debug append(10px 12px 16px, 25px); // 10px 12px 16px 25px
@debug append([col1-line1], col1-line2); // [col1-line1, col1-line2]

// index
@debug list.index(1px solid red, 1px); // 1
@debug list.index(1px solid red, solid); // 2
@debug list.index(1px solid red, dashed); // null

// nth
$valid-sides: left, center, right;

.screen-box {
  text-align : nth($valid-sides, 1); // left
}

λ³€μˆ˜ type - Maps

  • κ΄„ν˜Έ() μ•ˆμ— ν‚€: κ°’μ˜ ν˜•λŒ€λ‘œ μ €μž₯ν•˜μ—¬ μ‚¬μš©
    • ν‚€λŠ” κ³ μœ ν•΄μ•Ό ν•˜μ§€λ§Œ 킀에 ν•΄λ‹Ήν•˜λŠ” 값은 쀑볡 κ°€λŠ₯
  • λ³€μˆ˜λ₯Ό 각각 μ„ μ–Έν•˜λŠ” λŒ€μ‹ , κ΄€λ ¨μžˆλŠ” λ³€μˆ˜λ“€μ„ λͺ¨μ•„ Maps둜 λ§Œλ“€μ–΄μ„œ μ‚¬μš©ν•  수 μžˆλ‹€.
  • Maps κ΄€λ ¨ λ‚΄μž₯ ν•¨μˆ˜
    • get($map, $key) : 킀에 ν•΄λ‹Ήν•˜λŠ” 값을 리턴
$font-weights: ("regular": 400, "medium": 500, "bold": 700);

@debug map.get($font-weights, "medium"); // 500
@debug map.get($font-weights, "extra-bold"); // null

λ³€μˆ˜μ˜ Scope(μœ νš¨λ²”μœ„)

  • μ§€μ—­λ³€μˆ˜ : μ„ μ–Έν•œ μžκΈ°μžμ‹ μ„ 감싸고 μžˆλŠ” μ€‘κ΄„ν˜Έ{} μ•ˆμ—μ„œ μ‚¬μš©
    => ν•˜μœ„ λ‹¨κ³„μ˜ μ€‘κ΄„ν˜Έ{}μ—μ„œλ„ μ‚¬μš© κ°€λŠ₯
  • μ „μ—­λ³€μˆ˜ : κ°€μž₯ μœ— 뢀뢄에 μ •μ˜ν•˜μ—¬ 파일 λ‚΄ μ–΄λ””μ„œλ“ μ§€ μ‚¬μš© κ°€λŠ₯
    => μ „μ—­λ³€μˆ˜λ₯Ό 파일둜 λ§Œλ“€μ–΄μ„œ μ‚¬μš©ν•˜λŠ” 경우, 메인 scss νŒŒμΌμ—μ„œ μ „μ—­λ³€μˆ˜ νŒŒμΌμ„ λ‹€λ₯Έ νŒŒμΌλ“€λ³΄λ‹€ 상단에 μœ„μΉ˜ν•΄μ•Ό ν•œλ‹€.
$global-variable: global value;

.content {
  $local-variable: local value;
  global: $global-variable;
  local: $local-variable;
}

.sidebar {
  global: $global-variable;
  local: $local-variable;  // This would fail, because $local-variable isn't in scope.
}
  • !global : μ§€μ—­λ³€μˆ˜λ₯Ό μ „μ—­λ²”μœ„μ— ν• λ‹Ήν•˜μ—¬ μ „μ—­λ³€μˆ˜λ‘œ μ‚¬μš© κ°€λŠ₯
// scss
$variable: first global value;

.content {
  $variable: second global value !global;
  value: $variable;
}

.sidebar {
  value: $variable;
}
/* css */
.content {
  value: second global value;
}

.sidebar {
  value: second global value;
}

πŸ“Ž Operator

πŸ“Ž Mixin

πŸ“Ž Extend


마무리

  • 곰곰히 μƒκ°ν•΄λ³΄λ‹ˆ 졜근 μ•‘μ…˜ν”Œλžœ 1μˆœμœ„μ— 체λ ₯ 관리λ₯Ό μž‘μ„±ν•΄λ†“κ³  ν•  κ±° λ‹€~~~ ν•˜κ³  ν•˜λ£¨μ˜ λ„νŠΈλ¨Έλ¦¬μ— μ±™κ²Όλ‹€.
    => 어쩐지 μžμ „κ±° λŒλ¦¬λŠ”κ²Œ 점점 νž˜λ“€μ—ˆμ–΄
    => κ·Έλž˜μ„œ μ˜€λŠ˜μ€ νŠΉκ°• λλ‚˜κ³  λƒ…λ‹€ μžμ „κ±° λŒλ Έλ”λ‹ˆ 개운-
    => λ‚΄κ°€ μ–΄λ–€ 것을 μš°μ„ μ μœΌλ‘œ 생각할 지 λ˜λŒμ•„λ΄μ•Όκ² λ‹€.
  • Sass(SCSS)λ₯Ό λ°°μ›Œλ³΄κ³  μ‹Άμ—ˆλŠ”λ° 멋사... κ°μ‚¬ν•©λ‹ˆλ‹€β™‘
    => CSS둜 μž‘μ„± ν–ˆλ˜ νŒŒμΌμ„ SCSS둜 λ°”κΎΈλŠ” 건 κ½€λ‚˜ μ–΄λ ΅κ΅¬λ‚˜... ν•˜μ§€λ§Œ 즐겁, 꽀잼

0개의 λŒ“κΈ€