๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
JavaScript/React

[SCSS] ์˜จ๋ณด๋”ฉ 3์ฃผ 3์ผ์ฐจ - Swiper์™€ SCSS ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ

by junvely 2023. 3. 23.

๐Ÿฆ„ ์˜จ๋ณด๋”ฉ 3์ฃผ 2์ผ์ฐจ - SCSS ์„ค์น˜ ๋ฐ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ

โœจ03/22 : ๋ชฉํ‘œ : SCSS ์„ค์น˜ ๋ฐ ๊ธฐ๋ณธ ๋ฌธ๋ฒ• ์ตํžˆ๊ธฐ

Swiper๋ฅผ ์ด์šฉํ•ด ์Šฌ๋ผ์ด๋“œ๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ , SCSS๋กœ ์ปค์Šคํ„ฐ๋งˆ์ด์ง• ํ•ด๋ณด์ž.


01 Swiper ์Šฌ๋ผ์ด๋“œ ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ

1. Swiperํ™ˆํŽ˜์ด์ง€ => Demos => ๋ชฉ๋ก ์ค‘์—์„œ ์›ํ•˜๋Š” ์Šฌ๋ผ์ด๋“œ ๊ฐ€์ ธ์˜ค๊ธฐ

2. Core(html,css,js), React, Vue ๋“ฑ ์—ฌ๋Ÿฌ ์ข…๋ฅ˜๋กœ ์ฝ”๋“œ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

ํด๋ฆญํ•˜๋ฉด ์ฝ”๋“œ๊ฐ€ ์ญ‰ ๋‚˜์˜ค๋Š”๋ฐ ์ด ์ฝ”๋“œ๋ฅผ ๊ฐœ์ธ ํ”Œ์ ์— ์ฒจ๋ถ€ํ•˜๋ฉด ๋œ๋‹ค.

์ฃผ์˜ํ• ์ ์€1. script๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๊ฐ€์ ธ์™”๋Š”์ง€, 2.์Šฌ๋ผ์ด๋“œ๋Š” position ์„ค์ •์ด ์ค‘์š”ํ•œ๋ฐ, ์ฝ”๋“œ์—์„œ๋Š” ๋ณดํ†ต html์ด๋‚˜ body์— relative๊ฐ€ ๊ฑธ๋ ค์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์›ํ•˜๋Š” ์š”์†Œ์— ์˜ฎ๊ฒจ์„œ ์ž˜ ์กฐ์ •ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.

 

HTML

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css" />
<script src="https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js"></script>
<div class="slider">
        <h3 class="slider-title">์ด ์ƒํ’ˆ ์–ด๋•Œ์š”?</h3>
        <div class="swiper mySwiper">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <ul>
                        <li>
                            <div class="img-con">
                                <img src="https://product-image.kurly.com/product/image/469c0fc9-9f8d-46ae-becd-bda0098d965a.jpg" alt="product1">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[ํƒœ์šฐํ•œ์šฐ] 1+ ํ•œ์šฐ ๋“ฑ์‹ฌ 200g (๋ƒ‰์žฅ) 3์ข…</p>
                                <span class="sale sale-percent">15%</span>
                                <span class="sale sale-price">25,415์›~</span>
                                <span class="price">29,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1567506396267l0.jpg" alt="product2">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋‚˜ํƒˆ๋ฆฌ์Šค] ํ”„๋ฆฌ๋ฏธ์—„ ์ฐฉ์ฆ™ ์˜ค๋ Œ์ง€ ํŒŒ์ธ์• ํ”Œ 2์ข… (ํƒ1)</p>
                                <span class="sale sale-price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/cdn-cgi/image/quality=85,width=676/shop/data/goods/1653037164206l0.jpg" alt="product3">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฐ์ฒด์ฝ”] ์—‘์ŠคํŠธ๋ผ๋ฒ„์ง„ ์˜ฌ๋ฆฌ๋ธŒ ์˜ค์ผ</p>
                                <span class="sale sale-percent">10%</span>
                                <span class="sale sale-price">10,710์›~</span>
                                <span class="price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1657232326605l0.jpg" alt="product4">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฒ ์–ด๋ฒจ์Šค] ๋”๋ธ”๋ฐ”์ดํŠธ ํ”„๋กœํ‹ด๋ฐ” ์นด๋ผ๋ฉœ ํฌ๋ฆฌ์Šคํ”„ (2์ž…)</p>
                                <span class="sale sale-percent">6%</span>
                                <span class="sale sale-price">9,900์›</span>
                                <span class="price">10,600์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                    </ul>
                </div>
                <div class="swiper-slide">
                    <ul>
                        <li>
                            <div class="img-con">
                                <img src="https://product-image.kurly.com/product/image/469c0fc9-9f8d-46ae-becd-bda0098d965a.jpg" alt="product1">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[ํƒœ์šฐํ•œ์šฐ] 1+ ํ•œ์šฐ ๋“ฑ์‹ฌ 200g (๋ƒ‰์žฅ) 3์ข…</p>
                                <span class="sale sale-percent">15%</span>
                                <span class="sale sale-price">25,415์›~</span>
                                <span class="price">29,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1567506396267l0.jpg" alt="product2">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋‚˜ํƒˆ๋ฆฌ์Šค] ํ”„๋ฆฌ๋ฏธ์—„ ์ฐฉ์ฆ™ ์˜ค๋ Œ์ง€ ํŒŒ์ธ์• ํ”Œ 2์ข… (ํƒ1)</p>
                                <span class="sale sale-price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/cdn-cgi/image/quality=85,width=676/shop/data/goods/1653037164206l0.jpg" alt="product3">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฐ์ฒด์ฝ”] ์—‘์ŠคํŠธ๋ผ๋ฒ„์ง„ ์˜ฌ๋ฆฌ๋ธŒ ์˜ค์ผ</p>
                                <span class="sale sale-percent">10%</span>
                                <span class="sale sale-price">10,710์›~</span>
                                <span class="price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1657232326605l0.jpg" alt="product4">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฒ ์–ด๋ฒจ์Šค] ๋”๋ธ”๋ฐ”์ดํŠธ ํ”„๋กœํ‹ด๋ฐ” ์นด๋ผ๋ฉœ ํฌ๋ฆฌ์Šคํ”„ (2์ž…)</p>
                                <span class="sale sale-percent">6%</span>
                                <span class="sale sale-price">9,900์›</span>
                                <span class="price">10,600์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                    </ul>
                </div>
                <div class="swiper-slide">
                    <ul>
                        <li>
                            <div class="img-con">
                                <img src="https://product-image.kurly.com/product/image/469c0fc9-9f8d-46ae-becd-bda0098d965a.jpg" alt="product1">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[ํƒœ์šฐํ•œ์šฐ] 1+ ํ•œ์šฐ ๋“ฑ์‹ฌ 200g (๋ƒ‰์žฅ) 3์ข…</p>
                                <span class="sale sale-percent">15%</span>
                                <span class="sale sale-price">25,415์›~</span>
                                <span class="price">29,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1567506396267l0.jpg" alt="product2">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋‚˜ํƒˆ๋ฆฌ์Šค] ํ”„๋ฆฌ๋ฏธ์—„ ์ฐฉ์ฆ™ ์˜ค๋ Œ์ง€ ํŒŒ์ธ์• ํ”Œ 2์ข… (ํƒ1)</p>
                                <span class="sale sale-price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/cdn-cgi/image/quality=85,width=676/shop/data/goods/1653037164206l0.jpg" alt="product3">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฐ์ฒด์ฝ”] ์—‘์ŠคํŠธ๋ผ๋ฒ„์ง„ ์˜ฌ๋ฆฌ๋ธŒ ์˜ค์ผ</p>
                                <span class="sale sale-percent">10%</span>
                                <span class="sale sale-price">10,710์›~</span>
                                <span class="price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1657232326605l0.jpg" alt="product4">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฒ ์–ด๋ฒจ์Šค] ๋”๋ธ”๋ฐ”์ดํŠธ ํ”„๋กœํ‹ด๋ฐ” ์นด๋ผ๋ฉœ ํฌ๋ฆฌ์Šคํ”„ (2์ž…)</p>
                                <span class="sale sale-percent">6%</span>
                                <span class="sale sale-price">9,900์›</span>
                                <span class="price">10,600์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                    </ul>
                </div>
                <div class="swiper-slide">
                    <ul>
                        <li>
                            <div class="img-con">
                                <img src="https://product-image.kurly.com/product/image/469c0fc9-9f8d-46ae-becd-bda0098d965a.jpg" alt="product1">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[ํƒœ์šฐํ•œ์šฐ] 1+ ํ•œ์šฐ ๋“ฑ์‹ฌ 200g (๋ƒ‰์žฅ) 3์ข…</p>
                                <span class="sale sale-percent">15%</span>
                                <span class="sale sale-price">25,415์›~</span>
                                <span class="price">29,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1567506396267l0.jpg" alt="product2">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋‚˜ํƒˆ๋ฆฌ์Šค] ํ”„๋ฆฌ๋ฏธ์—„ ์ฐฉ์ฆ™ ์˜ค๋ Œ์ง€ ํŒŒ์ธ์• ํ”Œ 2์ข… (ํƒ1)</p>
                                <span class="sale sale-price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/cdn-cgi/image/quality=85,width=676/shop/data/goods/1653037164206l0.jpg" alt="product3">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฐ์ฒด์ฝ”] ์—‘์ŠคํŠธ๋ผ๋ฒ„์ง„ ์˜ฌ๋ฆฌ๋ธŒ ์˜ค์ผ</p>
                                <span class="sale sale-percent">10%</span>
                                <span class="sale sale-price">10,710์›~</span>
                                <span class="price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1657232326605l0.jpg" alt="product4">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฒ ์–ด๋ฒจ์Šค] ๋”๋ธ”๋ฐ”์ดํŠธ ํ”„๋กœํ‹ด๋ฐ” ์นด๋ผ๋ฉœ ํฌ๋ฆฌ์Šคํ”„ (2์ž…)</p>
                                <span class="sale sale-percent">6%</span>
                                <span class="sale sale-price">9,900์›</span>
                                <span class="price">10,600์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                    </ul>
                </div>
                <div class="swiper-slide">
                    <ul>
                        <li>
                            <div class="img-con">
                                <img src="https://product-image.kurly.com/product/image/469c0fc9-9f8d-46ae-becd-bda0098d965a.jpg" alt="product1">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[ํƒœ์šฐํ•œ์šฐ] 1+ ํ•œ์šฐ ๋“ฑ์‹ฌ 200g (๋ƒ‰์žฅ) 3์ข…</p>
                                <span class="sale sale-percent">15%</span>
                                <span class="sale sale-price">25,415์›~</span>
                                <span class="price">29,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1567506396267l0.jpg" alt="product2">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋‚˜ํƒˆ๋ฆฌ์Šค] ํ”„๋ฆฌ๋ฏธ์—„ ์ฐฉ์ฆ™ ์˜ค๋ Œ์ง€ ํŒŒ์ธ์• ํ”Œ 2์ข… (ํƒ1)</p>
                                <span class="sale sale-price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/cdn-cgi/image/quality=85,width=676/shop/data/goods/1653037164206l0.jpg" alt="product3">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฐ์ฒด์ฝ”] ์—‘์ŠคํŠธ๋ผ๋ฒ„์ง„ ์˜ฌ๋ฆฌ๋ธŒ ์˜ค์ผ</p>
                                <span class="sale sale-percent">10%</span>
                                <span class="sale sale-price">10,710์›~</span>
                                <span class="price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1657232326605l0.jpg" alt="product4">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฒ ์–ด๋ฒจ์Šค] ๋”๋ธ”๋ฐ”์ดํŠธ ํ”„๋กœํ‹ด๋ฐ” ์นด๋ผ๋ฉœ ํฌ๋ฆฌ์Šคํ”„ (2์ž…)</p>
                                <span class="sale sale-percent">6%</span>
                                <span class="sale sale-price">9,900์›</span>
                                <span class="price">10,600์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                    </ul>
                </div>
                <div class="swiper-slide">
                    <ul>
                        <li>
                            <div class="img-con">
                                <img src="https://product-image.kurly.com/product/image/469c0fc9-9f8d-46ae-becd-bda0098d965a.jpg" alt="product1">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[ํƒœ์šฐํ•œ์šฐ] 1+ ํ•œ์šฐ ๋“ฑ์‹ฌ 200g (๋ƒ‰์žฅ) 3์ข…</p>
                                <span class="sale sale-percent">15%</span>
                                <span class="sale sale-price">25,415์›~</span>
                                <span class="price">29,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1567506396267l0.jpg" alt="product2">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋‚˜ํƒˆ๋ฆฌ์Šค] ํ”„๋ฆฌ๋ฏธ์—„ ์ฐฉ์ฆ™ ์˜ค๋ Œ์ง€ ํŒŒ์ธ์• ํ”Œ 2์ข… (ํƒ1)</p>
                                <span class="sale sale-price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>
                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/cdn-cgi/image/quality=85,width=676/shop/data/goods/1653037164206l0.jpg" alt="product3">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฐ์ฒด์ฝ”] ์—‘์ŠคํŠธ๋ผ๋ฒ„์ง„ ์˜ฌ๋ฆฌ๋ธŒ ์˜ค์ผ</p>
                                <span class="sale sale-percent">10%</span>
                                <span class="sale sale-price">10,710์›~</span>
                                <span class="price">11,900์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                        <li>
                            <div class="img-con">
                                <img src="https://img-cf.kurly.com/shop/data/goods/1657232326605l0.jpg" alt="product4">
                                <i class="cart fa-solid fa-cart-plus"></i>
                            </div>
                            <div class="details">
                                <p class="title">[๋ฒ ์–ด๋ฒจ์Šค] ๋”๋ธ”๋ฐ”์ดํŠธ ํ”„๋กœํ‹ด๋ฐ” ์นด๋ผ๋ฉœ ํฌ๋ฆฌ์Šคํ”„ (2์ž…)</p>
                                <span class="sale sale-percent">6%</span>
                                <span class="sale sale-price">9,900์›</span>
                                <span class="price">10,600์›</span>
                                <span class="review"><i class="fa-regular fa-comment-dots"></i>ํ›„๊ธฐ 999+</span>

                            </div>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="swiper-button swiper-button-next"></div>
            <div class="swiper-button swiper-button-prev"></div>
        </div>    
    </div>
    <script>
        let swiper = new Swiper(".mySwiper", {
          navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
          },
        });
    </script>

 

- ์Šฌ๋ผ์ด๋“œ ์–‘ ์˜†์— ํ™”์‚ดํ‘œ ๋ฒ„ํŠผ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ::afterํƒœ๊ทธ์— ์Šคํƒ€์ผ์ด ๋“ค์–ด๊ฐ€ ์žˆ๋‹ค. ํ•„์š” ์‹œ CSS์—์„œ ํ•ด๋‹น ๋ฒ„ํŠผ์— ์Šคํƒ€์ผ์„ ์กฐ์ •ํ•˜๊ฑฐ๋‚˜ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋“ค์–ด๊ฐ€์žˆ๋Š” ๊ฐ€์ƒํƒœ๊ทธ์— ์Šคํƒ€์ผ์„ ์กฐ์ •ํ•ด ์ฃผ๋ฉด ๋œ๋‹ค.

 

02 SCSS ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ

1. SCSS ํด๋” ๊ตฌ์กฐ

- CSS์™€ SCSSํด๋” ๋”ฐ๋กœ ์ƒ์„ฑ => ์•ž์„œ ์ปดํŒŒ์ผ๋œ CSSํŒŒ์ผ์€ CSSํด๋”์— ์ €์žฅ๋˜๋„๋ก ํ•ด๋†จ๋‹ค.

SCSSํŒŒ์ผ์€ ์„œ๋ฒ„์—์„œ ๋ถˆํ•„์š”ํ•˜๋ฏ€๋กœ ๋นŒ๋“œ์—์„œ ์ œ์™ธ๋˜๋„๋ก ์„ค์ • ํ•œ๋‹ค.

 

2. _reset.scss / _variable.scss

_๊ฐ€ ๋“ค์–ด๊ฐ„ ํŒŒ์ผ์€ scss์—์„œ css๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์ž‘์—…์„ ๋ฌด์‹œํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ scssํŒŒ์ผ ์ด๋ฆ„ ์•ž์— _(์–ธ๋”๋ฐ”)๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด cssํด๋”์— ํ•ด๋‹น ํŒŒ์ผ์ด ์ถ”๊ฐ€๋˜์ง€ ์•Š๋Š”๋‹ค.

_reset.scss => ์ดˆ๊ธฐ์„ค์ • ํŒŒ์ผ

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap");

* {
  margin: 0;
  padding: 0;
  font-family: "Noto Sans KR", sans-serif;
}

ul,
li {
  list-style: none;
}

button,
input {
  border: none;
  background-color: transparent;
  cursor: pointer;
}

 

- variable => color, ๋ณ€์ˆ˜์„ค์ • ํŒŒ์ผ => ๋‚˜์ค‘์— color๋‚˜ font๋„ ๋”ฐ๋กœ ํŒŒ์ผ๋กœ ๊ตฌ์„ฑํ•ด ๋‘๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.

$color-purple: #5f0080;
$color-gray: #dddddd;
$color-light-gray: #f0f0f0;
$color-dark-gray: #424242;
$color-white: #fff;

@mixin flex-space-between {
  display: flex;
  justify-content: space-between;
}

@mixin flex-all-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

 

3. importํ•ด์„œ ์‚ฌ์šฉ

@import "./reset";
@import "./variable";

- @include : @mixin๋ณ€์ˆ˜ ๊ฐ€์ ธ์˜ค๊ธฐ

.swiper-slide {
      text-align: center;
      font-size: 18px;
      background: #fff;
      @include flex-all-center;
      }

- & :hover, active, checked, focus, ๋“ฑ๋“ฑ => ๋ถ€๋ชจ์— ํŠน์ • ํšจ๊ณผ ์‹œ ์‚ฌ์šฉ

.checkbox {
        display: none;

        &:checked + .custom-check {
          width: 20px;
          line-height: 20px;
          font-size: 13px;
          text-align: center;
          color: $color-white;
          background-color: rgb(255, 187, 0);
        }
      }

 

โ—์ถ”๊ฐ€์ ์œผ๋กœ, SCSS์—์„œ ์Šคํƒ€์ผ์ด ์ž˜ ๋จนํžˆ์ง€ ์•Š์„ ๊ฒฝ์šฐ, 1. Watching์ด ์ž˜ ๋˜๊ณ  ์žˆ๋Š”์ง€, 2. output ํ„ฐ๋ฏธ๋„ ์ฐฝ์— ์—๋Ÿฌ๊ฐ€ ๋‚œ ๊ณณ์ด ์žˆ๋Š”์ง€๋ฅผ ์ž˜ ํ™•์ธํ•ด ๋ณด์ž...(์™œ ์Šคํƒ€์ผ์ด ์•ˆ๋จน๋Š”์ง€ ๋ชฐ๋ผ์„œ ๊ณ„์† ์•  ๋จน์—ˆ๋‹ค.)

์•„์ง ์ž˜ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”์ง€๋Š” ์ž˜ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ๊ณ„์† ์‚ฌ์šฉํ•˜๋ฉด์„œ ์—ฐ์Šตํ•˜๋‹ค ๋ณด๋ฉด ๋” ๋ฐฐ์šธ ์ ์ด ๋งŽ์„ ๊ฒƒ ๊ฐ™๋‹ค!๐Ÿคญ

728x90
๋ฐ˜์‘ํ˜•