scss

kiseon·2024년 8월 5일
0

TIL

목록 보기
10/26

scss 변수

$red-color: #ff0000;

h1 {
  background-color: $red-color;
}

scss 중첩

반복을 최소화

사용

.social {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 600px;
    display: flex;

    li {
        border: 1px solid #000;
        padding: 10px;
        flex: 1;
        text-align: center;

        a {
            color: #000;
            text-transform: uppercase;
        }
    }
}

&

scss 믹스인

재사용이 가능한 스타일을 정의

//예시
<section>
     <h1 class="font-large"><a>This is H1 Headline</a></h1>
     <h2 class="font-medium"><a>This is H2 Headline</a></h2>
     <h3 class="font-small"><a>This is H3 Headline</a></h3>
</section>
.font {
    &-large {
        color: crimson;
        text-transform: uppercase;
        a {
        font-size: 60px;
        }
    }

    &-medium {
        font-size: 40px;
        color: yellowgreen;
        text-transform: uppercase;
    }

    &-small {
        font-size: 20px;
        color: royalblue;
        text-transform: uppercase;
    }
}

선언

@mixin reusable-style {
  color: red;
  margin: 0;
}

사용

div {
  @include resuable-style;
}

인수

선언

@mixin mixin-with-args($props, $num) {
  #{$props}: $num;
}

사용

.box1 {
  @include mixin-with-args(width, 100px);
}

참고
https://velog.io/@bami/SCSS-SCSS-%EB%AC%B8%EB%B2%955-mixin-inclue

profile
되고싶다.. 개발자..!

2개의 댓글

comment-user-thumbnail
2024년 8월 5일

오 정리도 이해쉽게 정리하는 모습 좋습니다.

답글 달기
comment-user-thumbnail
2024년 8월 14일

간략하게 딱 적어두셔서 이해가 편해요

답글 달기