SASS(SCSS) Tutorial #2

· 6년 전 · 1043

7. Pseudo Classes

#main-nav a:hover {

  background: #333;

}

는 다음과 같이 

a{

  &:hover{

    background: #333;

  }

}

float후에 사용되는 아래와 같은 것도 mixin으로 처리한후에 사용함.

@mixin clearFix{

  &:after{

    content: "";

    display: block;

    clear: both;

  }

}

8. Mathematical Operators

*, /, +, - 를 사용가능함.

width: (100% / 6) 

9. Creating a Grid with SASS Math

mixin과 math를 이용해서 grid를 자동으로 설정가능함.   동영상을 꼭보세요.

sass의 장점이 여기에서 나오기 시작합니다.

 

@mixin grid($cols, $mgn) {
    float: left;
    margin-right: $mgn;
    margin-bottom: $mgn;
    width: ((100% - (($cols - 1) * $mgn)) / $cols);
    &:nth-child(#{$cols}n) {
        margin-right: 0;
    }
}

 

10. Colour Functions

http://sass-lang.com/documentation/Sass/Script/Functions.html

 

lighten($deepBlue, 5)

complement($deepBlue)

 

11. The @Content Keyword

@content 는 말로 설명하기 어려우니 동영상을 꼭 보세요.

 

12. If Statements

멀티불 인자를 넘겨줄수도 있습니다.

@mixin mQ($arg...){
    @if length($arg) == 1{
        @media screen and (max-width: nth($arg, 1)){
            @content;
        }
    }
    @if length($arg) == 2{
        @media screen and (max-width: nth($arg, 1) and (min-width: nth($arg, 2))){
            @content;
        }
    }
}

 

 

 

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

CSS

CSS 관련 공부 및 자료 공유 소모임 게시판 입니다.

+
제목 글쓴이 날짜 조회
5년 전 조회 1,824
5년 전 조회 1,530
5년 전 조회 2,394
6년 전 조회 1,719
6년 전 조회 1,564
6년 전 조회 1,551
6년 전 조회 1,506
6년 전 조회 1,499
6년 전 조회 1,685
6년 전 조회 1,853
6년 전 조회 1,315
6년 전 조회 2,705
6년 전 조회 1,473
6년 전 조회 1,370
6년 전 조회 1,044
6년 전 조회 2,269
6년 전 조회 1,292
6년 전 조회 1,207
6년 전 조회 1,026
6년 전 조회 1,392
6년 전 조회 943
6년 전 조회 1,127
6년 전 조회 1,011
6년 전 조회 1,334
6년 전 조회 1,838
6년 전 조회 1,296
6년 전 조회 1,217
6년 전 조회 1,491
6년 전 조회 1,355
6년 전 조회 1,028
🐛 버그신고