10. SCSS

SCSS의 기본 사용법에 대해서 알아본다.

vite + react + typescript + swc + scss 설치

npm create vite@latest my-app -- --template react-swc-ts
npm install -D sass

기본 사용법

1. css file 의 확장자를 .scss 로 변경

<link rel="stylesheet" href="./index.scss" />

3. Nesting

ul {
  list-style-type: none;
  padding: 0;
  display: flex;
  gap: 10px;
  padding: 10px;

  li {
    background-color: tomato;
    color: white;
    padding: 10px;
    border-radius: 7px;

    a {
      text-decoration: none;
      color: white;
      text-transform: uppercase;
    }

    &:hover {
      opacity: 0.8;

      a {
        color: gray;
      }
    }
  }
}

4. mixin

5. mixin with content

6. mixin with midea query

Last updated