๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์• ๋‹ˆ๋ฉ”์ด์…˜

CSS์• ๋‹ˆ๋ฉ”์ด์…˜ ์˜ˆ์‹œ

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

CSS animation

๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•

1. ์• ๋‹ˆ๋ฉ”์ด์…˜์œผ๋กœ ๋งŒ๋“ค๊ณ  ์‹ถ์€ ์ด๋ฏธ์ง€๋ฅผ ํ”„๋ ˆ์ž„ ์ˆ˜๋งŒํผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.(์—ฐ์†๋˜๋Š” ์ด๋ฏธ์ง€๋กœ ๊ฐ€์ ธ์™€์ฃผ์„ธ์š”) 2. ์ด๋ฏธ์ง€๋“ค์„ ํ•˜๋‚˜๋กœ ์ด์–ด ๋ถ™์ž…๋‹ˆ๋‹ค. ํฌํ† ์ƒต์—์„œ (์ด๋ฏธ์ง€์˜ ๋„ˆ๋น„) X (ํ”„๋ ˆ์ž„ ์ˆ˜) ๋งŒํผ์˜ ๋„ˆ๋น„๋กœ ์ƒˆ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ์ˆœ์„œ๋Œ€๋กœ ์ด์–ด๋ถ™์ด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. 3. ๊ทธ ์ด๋ฏธ์ง€๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. 4. ์ด ์ด๋ฏธ์ง€๋ฅผ CSS์˜ background๋ฅผ ์ด์šฉํ•˜์—ฌ ๋„ฃ์–ด์ค„ ์œ„์น˜์— ์œ„์น˜์‹œํ‚ต๋‹ˆ๋‹ค. 5. ์• ๋‹ˆ๋ฉ”์ด์…˜ํšจ๊ณผ๋ฅผ ๋ถ€์—ฌํ•ฉ๋‹ˆ๋‹ค. ์†Œ์Šค๋Š” ์•„๋ž˜์˜ ์†Œ์Šค๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

HTML ์†Œ์Šค

<div class="sample">
    <div class="timing step">
        <div class="stepbox"></div>
    </div>
</div>

.step {
    height: 700px;
    background: #333;
    position: relative;
}
.step .stepbox {
    width: 800px; height: 600px;
    background: url(https://github.com/Youcodein/coding2/blob/main/animation/img/cupani.jpg?raw=true);
    border-radius: 0;
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    animation: ani 1s steps(32, start) infinite;
}

@keyframes ani {
    0% {background-position: 0 0;}
    100% {background-position: -25600px 0;}
}

$(".start2").click(function(){
$(".timing.bg2 > div").addClass("show");
setTimeout(function(){
$(".timing.bg2 > div").removeClass("show");
},4000);
});
728x90
๋ฐ˜์‘ํ˜•

'์• ๋‹ˆ๋ฉ”์ด์…˜' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

SVG ์• ๋‹ˆ๋ฉ”์ด์…˜ ์˜ˆ์‹œ  (2) 2022.09.08
์• ๋‹ˆ๋ฉ”์ด์…˜ - CSS  (4) 2022.09.08
์• ๋‹ˆ๋ฉ”์ด์…˜ - SVG  (5) 2022.09.07

๋Œ“๊ธ€