ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • scss
    html.css.js/html css 2023. 11. 9. 09:27

    ๐Ÿฅ• SCSS ๋ž€? ( Syntactically Awesome StyleSheet์˜ ์•ฝ์–ด )

    Sass์˜ 3๋ฒ„์ „์—์„œ ์ƒˆ๋กญ๊ฒŒ ๋“ฑ์žฅํ•œ SCSS๋Š” CSS ๊ตฌ๋ฌธ๊ณผ ์™„์ „ํžˆ ํ˜ธํ™˜๋˜๋„๋ก ์ƒˆ๋กœ์šด ๊ตฌ๋ฌธ์„ ๋„์ž…ํ•ด ๋งŒ๋“  Sass์˜ ๋ชจ๋“  ๊ธฐ๋Šฅ์„ ์ง€์›ํ•˜๋Š” CSS์˜ ์ƒ์œ„์ง‘ํ•ฉ(Superset)
    => ์›น์—์„œ๋Š” ์ง์ ‘ ๋™์ž‘ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— CSS๋กœ ์ปดํŒŒ์ผ(Compile)ํ•จ

    ๐Ÿฅ• SCSS ์™œ ์“ธ๊นŒ?

    ๊ฐœ๋ฐœ์˜ ํšจ์œจ์„ ์˜ฌ๋ฆฌ๊ธฐ ์œ„ํ•ด ๋“ฑ์žฅํ•œ CSS ์ „์ฒ˜๋ฆฌ๊ธฐ ์–ธ์–ด

    1. ์ฝ”๋“œ์˜ ์žฌํ™œ์šฉ์„ฑ

    2. ๊ฐ€๋…์„ฑ

    => CSS์—์„œ ๋ณด์ด๋˜ ๋‹จ์ ์„ ๋ณด์™„ํ•จ

    ๐Ÿฅ• ์ค‘์ฒฉ(Nesting)

    ์ƒ์œ„ ์„ ํƒ์ž์˜ ๋ฐ˜๋ณต์„ ํ”ผํ•˜๊ณ  ๊ฐ€๋…์„ฑ์ด ์ข‹๊ฒŒ ์ž‘์„ฑ ๊ฐ€๋Šฅ
    .box {
      margin: {
        top: 10vh;
        left: 20vw;
      };
      padding: {
        bottom: 40vh;
        right: 30vw;
      };
      .list {
      	padding: 20px;
        	li {
            	text-decoration: none;
                }
       }         
    }

    ๐Ÿฅ• ์ฐธ์กฐ

    ์ค‘์ฒฉ ์•ˆ์—์„œ &ํ‚ค์›Œ๋“œ๋Š” ์ƒ์œ„(๋ถ€๋ชจ)์„ ํƒ์ž๋ฅผ ์ฐธ์กฐํ•จ
    .btn {
      position: absolute;
      &.active {
        color: red;
      }
    }
    .btn {
      color: blue;
      &:hover {
        color: red;
      }
    }

    ๐Ÿฅ• ์žฌํ™œ์šฉ

    SCSS๋Š” @mixin๊ณผ @include๋กœ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉ

     

    @Mixins

    ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๊ธฐ๋Šฅ์„ ๋งŒ๋“œ๋Š” ๋ฐฉ์‹
    @mixin ๋ฏน์Šค์ธ์ด๋ฆ„ {
      ์Šคํƒ€์ผ;
    }
    @mixin largeBtn {
        border-radius: 50%;
        border: none;
        background-color: white;
        width: 2vw;
        height: 5vh;
    }

     

     @include

    @include ๋ฏน์Šค์ธ์ด๋ฆ„;

     

    ๐Ÿฅ• ํ™•์žฅ (extend)

    ํŠน์ • ์„ ํƒ์ž๊ฐ€ ๋‹ค๋ฅธ ์„ ํƒ์ž์˜ ๋ชจ๋“  ์Šคํƒ€์ผ์„ ๊ฐ€์ ธ์•ผํ•˜๋Š” ๊ฒฝ์šฐ
    @extend ์„ ํƒ์ž;
    .btn {
      padding: 20px;
      margin: 20px;
      background: skyblue;
    }
    .btn-agree {
      @extend .btn;
      background: green;
    }

    ๐Ÿฅ•if (ํ•จ์ˆ˜)

    // @if
    if(์กฐ๊ฑด, ํ‘œํ˜„์‹1, ํ‘œํ˜„์‹2)
    	/* ์กฐ๊ฑด์ด ์ฐธ์ผ ๋•Œ ํ‘œํ˜„์‹1, ๊ฑฐ์ง“์ผ ๋•Œ ํ‘œํ˜„์‹2 */
    
    // @if @else
    @if (์กฐ๊ฑด) {
    	/* ์กฐ๊ฑด์ด ์ฐธ์ผ ๋•Œ ๊ตฌ๋ฌธ */
    } @else {
    	/* ์กฐ๊ฑด์ด ๊ฑฐ์ง“์ผ ๋•Œ ๊ตฌ๋ฌธ */
    }
    
    // @if @else if
    @if (์กฐ๊ฑด1) {
    	/* ์กฐ๊ฑด1์ด ์ฐธ์ผ ๋•Œ ๊ตฌ๋ฌธ */
    } @else if (์กฐ๊ฑด2) {
    	/* ์กฐ๊ฑด2๊ฐ€ ์ฐธ์ผ ๋•Œ ๊ตฌ๋ฌธ */
    } @else {
    	/* ๋ชจ๋‘ ๊ฑฐ์ง“์ผ ๋•Œ ๊ตฌ๋ฌธ */
    }

    => ์กฐ๊ฑด์— ( )๋Š” ์ƒ๋žต์ด ๊ฐ€๋Šฅ

    'html.css.js > html css' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

    ๊ทธ๋ฆฌ๋“œ [grid]  (0) 2023.12.15
    web๋™์ž‘์›๋ฆฌ  (2) 2023.11.15
    [CSS] Flex์†์„ฑ  (0) 2023.08.07
Designed by Tistory.