SASS(SCSS) Tutorial #2

· 7년 전 · 1260

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년 전 조회 2,021
5년 전 조회 1,757
5년 전 조회 2,645
6년 전 조회 1,937
6년 전 조회 1,781
6년 전 조회 1,761
6년 전 조회 1,713
6년 전 조회 1,696
7년 전 조회 1,909
7년 전 조회 2,062
7년 전 조회 1,522
7년 전 조회 2,893
7년 전 조회 1,668
7년 전 조회 1,586
7년 전 조회 1,261
7년 전 조회 2,484
7년 전 조회 1,495
7년 전 조회 1,439
7년 전 조회 1,237
7년 전 조회 1,600
7년 전 조회 1,162
7년 전 조회 1,364
7년 전 조회 1,246
7년 전 조회 1,553
7년 전 조회 2,078
7년 전 조회 1,528
7년 전 조회 1,448
7년 전 조회 1,722
7년 전 조회 1,595
7년 전 조회 1,260