๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Site

[์‚ฌ์ดํŠธ ๋งŒ๋“ค๊ธฐ] ์ด๋ฏธ์ง€ ์œ ํ˜• 02 - Transition & Hover ํ™œ์šฉํ•˜๊ธฐ

by ์ฝ”๋”ฉ๊ณต์ฑ… 2022. 8. 17.
๋ฐ˜์‘ํ˜•

์‚ฌ์ดํŠธ ๋งŒ๋“ค๊ธฐ : ์ด๋ฏธ์ง€ ์œ ํ˜• 02

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Figma์—์„œ ๋งŒ๋“  ์ด๋ฏธ์ง€ ์œ ํ˜• ์„น์…˜์„ HTML๊ณผ CSS ์ฝ”๋“œ๋กœ ์˜ฎ๊ธฐ๋Š” ์ž‘์—…์„ ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


Figma

๋จผ์ € ๋งŒ๋“ค๊ณ ์ž ํ•˜๋Š” ์›น ์‚ฌ์ดํŠธ์˜ ๋ชจ์–‘์„ Figma๋ผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ด์šฉํ•˜์—ฌ ์•„๋ž˜์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด์ฃผ๋„๋ก ํ•˜์ž.
์ด๋ฒˆ์— ๋งŒ๋“ค ์›น ์‚ฌ์ดํŠธ์˜ ์œ ํ˜•์€ ์ด๋ฏธ์ง€ ์œ„์— ์ œ๋ชฉ๊ณผ ์ž์„ธํžˆ ๋ณด๊ธฐ ๋ฒ„ํŠผ์„ ์˜ฌ๋ ค๋†“๊ณ  ๊ทธ๊ฑธ hover ํšจ๊ณผ๋กœ ์œ„๋กœ ๋‚˜ํƒ€๋‚˜๊ฒŒ ํ•˜๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ฃผ๋„๋ก ํ•˜๊ฒ ๋‹ค.

HTML ์†Œ์Šค

์›น ํ‘œ์ค€ ์ค€์ˆ˜๋ฅผ ์œ„ํ•ด ์‹œ๋งจํ‹ฑ ํƒœ๊ทธ๋ฅผ ์ ๊ทน ์‚ฌ์šฉํ•˜๋„๋ก ํ•˜์ž. ์ž์„ธํ•œ ์„ค๋ช…์€ ์•„๋ž˜ ์˜ˆ์‹œ ์ฝ”๋“œ์˜ ์ฃผ์„์ฒ˜๋ฆฌ ๋‚ด์šฉ์„ ์ฐธ์กฐํ•  ๊ฒƒ.

<body>
    <section id="imageType02" class="image__wrap gmarket section">
        <h1>๋ณ„๋น› ์ œ๋นต๊ต์‹ค ๊ฐ•์‚ฌ ์†Œ๊ฐœ๐Ÿž</h1>
        <p>์‚ฌ๋žŒ ์•„๋‹Œ ๋™๋ฌผ์ด์ง€๋งŒ ํ›Œ๋ฅญํ•œ ์‹ค๋ ฅ์„ ๊ฐ€์ง„ ๋ณ„๋น› ์ œ๋นต๊ต์‹ค์˜ ๊ฐ•์‚ฌ๋ถ„๋“ค์„ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค!</p>
        <div class="image__inner container">
            <article class="image img1">
                <figure class="image__box">
                    <img src="img/imageType02_bg01.jpg" alt="๋Œ•๋Œ•์ด">
                </figure>
                <div class="image__desc">
                    <h3>๋Œ•๋Œ•์ด</h3>
                    <a href="/" class="more" title="์ž์„ธํžˆ ๋ณด๊ธฐ">์ž์„ธํžˆ ๋ณด๊ธฐ</a>
                </div>
            </article>
            <article class="image img2">
                <figure class="image__box">
                    <img src="img/imageType02_bg02.jpg" alt="๋ƒฅ๋ƒฅ์ด">
                </figure>
                <div class="image__desc">
                    <h3>๋ƒฅ๋ƒฅ์ด</h3>
                    <a href="/" class="more" title="์ž์„ธํžˆ ๋ณด๊ธฐ">์ž์„ธํžˆ ๋ณด๊ธฐ</a>
                </div>
            </article>
            <article class="image img3">
                <figure class="image__box">
                    <img src="img/imageType02_bg03.jpg" alt="๋ถ๊ทน๊ณฐ">
                </figure>
                <div class="image__desc">
                    <h3>๋ถ๊ทน๊ณฐ</h3>
                    <a href="/" class="more" title="์ž์„ธํžˆ ๋ณด๊ธฐ">์ž์„ธํžˆ ๋ณด๊ธฐ</a>
                </div>
            </article>
        </div>
    </section>
</body>

CSS ์†Œ์Šค

reset์—์„œ margin๊ฐ’๊ณผ padding๊ฐ’์„ 0์œผ๋กœ ์ดˆ๊ธฐํ™” ์‹œํ‚ค๋Š” ์ž‘์—…๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ๋‹ค.
๋˜ํ•œ, ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ๋ฅผ ์ฃผ๊ธฐ ์œ„ํ•ด transition ์†์„ฑ๊ณผ :hover ์†์„ฑ์„ ์ ๊ทน ํ™œ์šฉํ•œ๋‹ค.
์ž์„ธํ•œ ์„ค๋ช…์€ ์•„๋ž˜ ์˜ˆ์‹œ ์ฝ”๋“œ์˜ ์ฃผ์„์ฒ˜๋ฆฌ๋œ ๋‚ด์šฉ์„ ์ฐธ์กฐํ•  ๊ฒƒ.

<style>
    /* fonts */
    @import url('https://webfontworld.github.io/gmarket/GmarketSans.css');

    .gmarket {
        font-family: 'GmarketSans';
        font-weight: 400;
    }

    /* reset */
    * {
        margin: 0;
        padding: 0;
    }
    h1, h2, h3, h4, h5, h6 {
        font-weight: normal;
    }
    a {
        text-decoration: none;
        color: #000;
    }
    img {
        width: 100%;    /* ์ด๋ฏธ์ง€ ํŠ€์–ด๋‚˜์˜จ ๊ฑฐ ์ง‘์–ด๋„ฃ๊ธฐ */
    }

    /* common */
    .container {
        width: 1160px;
        padding: 0 20px;
        margin: 0 auto;
        min-width: 1160px;  /* ๋ฐ˜์‘ํ˜• ํ•  ๋•Œ ์—†์• ์ค„ ๊ฒƒ */
    }
    .section {
        padding: 120px 0;
    }
    .section > h1 {
        font-size: 50px;
        line-height: 1;
        text-align: center;
        margin-bottom: 20px;
    }
    .section > p {
        font-size: 22px;
        font-weight: 300;
        text-align: center;
        margin-bottom: 70px;
        color: #666;
    }

    /* imageType */
    .image__inner {
        display: flex;
        justify-content: space-between;
    }
    .image {
        width: 32%;
        position: relative;
        overflow: hidden;
    }
    .image__box {
        height: 100%;
    }
    .image__box img {
        transition: all 0.5s ease-in-out;   /* 0.5์ดˆ๋™์•ˆ ๊ฑธ์ณ ๋ณ€ํ™” ์ฃผ๋„๋ก ์• ๋‹ˆ๋ฉ”์ด์…˜ ์„ค์ • */
    }
    .image__desc {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        text-align: center;
        padding: 20px;
        box-sizing: border-box;     /* image__desc ๋ฐ•์Šค ์•ˆ๋„˜์น˜๊ฒŒ ํ•˜๊ธฐ */
        backdrop-filter: blur(10px);
        transition: all 0.3s ease-in-out;
    }

    /* ์ด๋ฏธ์ง€ ์„ค๋ช…์นธ ๋ฐฐ๊ฒฝ์ƒ‰, h3/more ๊ธ€์”จ์ƒ‰์ƒ ์„ค์ • */
    .img1 > .image__desc {
        background: rgba(178, 82, 36, 0.5);
    }
    .img1 > .image__desc h3 {
        color: #fff;
    }
    .img1 > .image__desc .more {
        color: #fff;
    }
    .img2 > .image__desc {
        background-color: rgba(187, 238, 239, 0.5);
    }
    .img2 > .image__desc h3 {
        color: #006462;
    }
    .img2 > .image__desc .more {
        color: #006462;
    }
    .img3 > .image__desc {
        background-color: rgba(161, 166, 172, 0.5);
    }
    .img3  > .image__desc h3 {
        color: #183169;
    }
    .img3  > .image__desc .more {
        color: #183169;
    }

    /* ์œ„๋กœ ์˜ฌ๋ผ์˜ค๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ฃผ๊ธฐ ์œ„ํ•ด hover ํšจ๊ณผ ์ฃผ๊ธฐ */
    .img1 .image__desc {
        bottom: -100px;
    }
    .img1:hover .image__desc {
        bottom: 0;
    }
    .img2 .image__desc {
        bottom: -100px;
    }
    .img2:hover .image__desc {
        bottom: 0;
    }
    .img3 .image__desc {
        bottom: -100px;
    }
    .img3:hover .image__desc {
        bottom: 0;
    }

    .image:hover .image__box img {
        transform: scale(1.05);     /* ๋งˆ์šฐ์Šค ์ปค์„œ ์˜ฌ๋ฆฌ๋ฉด 1.05์ •๋„ ์ด๋ฏธ์ง€ ํ‚ค์›Œ์คŒ */
    }

    /* ์ด๋ฏธ์ง€ ์„ค๋ช…์นธ ๊ธ€์”จ ํฌ๊ธฐ์™€ margin๊ฐ’ ๋“ฑ๋“ฑ... */
    .image__desc h3 {
        font-size: 24px;
        margin-bottom: 5px;
    }
    .image__desc .more {
        font-size: 16px;
        font-weight: 300;
    }
    .image__desc .more:hover {
        text-decoration: underline;
    }
</style>

์ตœ์ข… ๊ฒฐ๊ณผ

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€


Reference Book

JavaScript
HTML
CSS
๊ด‘๊ณ  ์ค€๋น„์ค‘์ž…๋‹ˆ๋‹ค.