๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Site ์ œ์ž‘

์‚ฌ์ดํŠธ ์ œ์ž‘ - ์™„์„ฑ๋ณธ / ๋ฐ˜์‘ํ˜•

by Youcodein 2022. 9. 19.
728x90
๋ฐ˜์‘ํ˜•

์‚ฌ์ดํŠธ ๋งŒ๋“ค๊ธฐ ํ•ฉ๋ณธ(์ง„ํ–‰์ค‘)

์ด๋•Œ๊นŒ์ง€ ๋ฐฐ์šด ์œ ํ˜•๋“ค์„ ํ™œ์šฉํ•˜์—ฌ ์‚ฌ์ดํŠธ๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

๊ณผ์ •

1. ํ”ผ๊ทธ๋งˆ๋กœ ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

2. ์ด๋•Œ๊นŒ์ง€ ๋งŒ๋“ค์–ด๋‘” ์œ ํ˜•๋“ค์„ ์กฐํ•ฉํ•˜์—ฌ ์‚ฌ์ดํŠธ ์ฝ”๋”ฉ์„ ํ•ฉ๋‹ˆ๋‹ค.

๊ฐ๊ฐ์˜ ์œ ํ˜•๋ณ„ ์ฝ”๋”ฉ ๋ฐฉ๋ฒ•์€ ๋งํฌ๋ฅผ ์ฐธ์กฐํ•ด์ฃผ์„ธ์š”.

1. ํ—ค๋” ์œ ํ˜•
2. ์Šฌ๋ผ์ด๋“œ ์œ ํ˜•
3. ์ด๋ฏธ์ง€ ์œ ํ˜•
4. ์ด๋ฏธ์ง€/ํ…์ŠคํŠธ ์œ ํ˜•
5. ์นด๋“œ ์œ ํ˜•
6. ๋ฐฐ๋„ˆ ์œ ํ˜•
7. ํ…์ŠคํŠธ ์œ ํ˜•
8. ํ‘ธํ„ฐ ์œ ํ˜•

๋˜ํ•œ html๊ณผ css ์†Œ์Šค ์—ญ์‹œ ์†Œ์Šค๋ณด๊ธฐ๋ฅผ ํ†ตํ•ด ํ™•์ธํ•ด์ฃผ์„ธ์š”!

3. ๋ฐ˜์‘ํ˜• ์ž‘์—…์„ ํ•ฉ๋‹ˆ๋‹ค.

๋‹ค๋ฅธ ์ข…๋ฅ˜์˜ ๋””๋ฐ”์ด์Šค์—์„œ๋„ ์‚ฌ์ดํŠธ๊ฐ€ ์ž˜ ์ž‘๋™ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ๋ฐ˜์‘ํ˜• ์ž‘์—…์„ ํ•ด์ค๋‹ˆ๋‹ค.

3-2. ํ—ค๋”๊ฐ€ ๊นจ์ง€๋Š” ๋ฌธ์ œ ๋ฐœ์ƒ

ํ™”๋ฉด ํฌ๊ธฐ๋ฅผ ์ค„์˜€์„ ๋•Œ ํ—ค๋”์˜ ๊ธ€์”จ๊ฐ€ ๊นจ์ง€๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค
๋ฌธ์ œ ํ•ด๊ฒฐ์„ ์œ„ํ•ด ํ–„๋ฒ„๊ฑฐ ๋ฉ”๋‰ด๋ฅผ ์ƒ์„ฑํ•ด์ค๋‹ˆ๋‹ค.

3-3. ๋ฐ˜์‘ํ˜• ๋ฉ”๋‰ด ๋‚˜์˜ค๊ฒŒ ํ•˜๊ธฐ

ํ–„๋ฒ„๊ฑฐ ๋ฉ”๋‰ด ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ ํ•˜์œ„ ๋ฉ”๋‰ด๊ฐ€ ๋‚˜์˜ค๊ฒŒ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

4. ๋ฒ„๊ทธ๋ฅผ ํ™•์ธํ•˜๋ฉฐ ๋ฒ„๊ทธ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ฉ๋‹ˆ๋‹ค.

Javascript

var swiper = new Swiper(".mySwiper", {
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
    autoplay: {
        delay: 2000,
        disableOnInteraction: false,
    },
    pagination: {
        el: '.swiper-pagination',
        type: 'bullets',
        clickable: true,
    },
});

const btnStop = document.querySelector(".swiper-button-stop");
const btnStart = document.querySelector(".swiper-button-stop");
const btnHam = document.querySelector(".header__ham");
const btnMenu = document.querySelector(".header__menu");
const btnMenuList = btnMenu.querySelectorAll("ul li a");

btnStart.style.display = "none";

document.querySelector(".swiper-button-stop").addEventListener("click", () => {
    swiper.autoplay.stop();
    btnStart.style.display = "block";
    btnStop.style.display = "none";

});
document.querySelector(".swiper-button-play").addEventListener("click", () => {
    swiper.autoplay.start();
    btnStart.style.display = "none";
    btnStop.style.display = "block";
});

btnHam.addEventListener("click", () => {
    btnHam.classList.toggle("active");
    btnMenu.classList.toggle("active");
    document.body.classList.toggle("fixed");

})

btnMenuList.forEach((List)=>{
    List.addEventListener("click", ()=>{
        btnMenu.classList.remove("active");
        btnHam.classList.remove("active");
        document.body.classList.remove("fixed");
    })
})

window.addEventListener("resize", () => {
    let width = window.innerWidth;
    if (width > 1300) {
        document.body.classList.remove("fixed");
        btnMenu.classList.remove("active");
        btnHam.classList.remove("active");

    }
});

document.querySelectorAll("a").forEach(li => {
    li.addEventListener("click", (e) => {
        e.preventDefault();
        document.querySelector(li.getAttribute("href")).scrollIntoView({
            behavior:"smooth"
        });
    });
});
    
728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€