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

[CSS] ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹ค์Šต : ์›€์ง์ด๋Š” ๋ฐ•์Šค

by _ํ† ๋งคํ†  2022. 8. 30.
728x90

CSS : ์• ๋‹ˆ๋ฉ”๋‹ˆ์…˜ ๋งŒ๋“ค๊ธฐ : ๋ฐ•์Šค

์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” CSS์‹ค์Šต์œผ๋กœ ๊ท€์—ฌ์šด ๋ฐ•์Šค ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“ค์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜„


#1. HTML

๋จผ์ € HTML ์ฝ”๋“œ๋กœ div๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐ•์Šค๋ฅผ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค.

<div class="box"></div>

#2. CSS

๋‹ค์Œ์€ CSS ์†์„ฑ์ž…๋‹ˆ๋‹ค. animation ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ keyframes์— ์ ์šฉํ•  ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ช…์„ ์ž‘์„ฑํ•ด์ฃผ๊ณ  ๊ทธ ์™ธ ์†์„ฑ์„ ์„ค์ •ํ•ด์ค๋‹ˆ๋‹ค.
@keyframes์— ์†์„ฑ์„ ์„ค์ •ํ•  ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ช…์„ ์จ์ค€๋’ค ๊ฐ 0% ~ 100% ์‚ฌ์ด์— ์†์„ฑ์„ ๋ถ€์—ฌํ•ด์ค๋‹ˆ๋‹ค.

body {
  height: 100vh;
  background-image: linear-gradient(to top, Plum, skyblue);
}

.box {
  width: 50px;
  height: 50px;
  position: absolute; /* ์œ„์น˜ ์žก๊ธฐ */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
}

.box::before {
  content:'';
  width: 50px;
  height: 5px;
  background: #000;
  position: absolute;
  top: 58px;
  left: 0;
  border-radius: 50%;
  opacity: 0.2;
  animation: shadow 0.6s linear infinite; /* ๋ฌดํ•œ์œผ๋กœ ๋Œ๋ฆฌ๊ธฐ */
}

@keyframes shadow {
  0% {transform: scale(1, 1);}
  50% {transform: scale(1.2, 1);}
  100% {transform: scale(1, 1);}
}

.box::after {
  content: '';
  background: pink;
  width: 50px;
  height: 50px;
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 3px;
  animation: load 0.6s linear infinite;
}

@keyframes load {
  17% {
    border-bottom-right-radius: 3px;
  } /* ๊ธฐ๋ณธ ๋ชจ์–‘์œผ๋กœ ํŠน๋ณ„ํ•œ ํšจ๊ณผ๋Š” ์—†๋‹ค. */
  25% {
    transform: translatey(9px) rotate(22.5deg);
  }
  50% {
    transform: translatey(18px) scale(1, 0.9)rotate(45deg);
    border-bottom-right-radius: 40px;
  } 
  75%   {
    transform: translatey(9px) rotate(67.5deg);
  }
  100%  {
    transform: translatey(0px) rotate(90deg);
  }
}

#3. ๊ฒฐ๊ณผ๋ณด๊ธฐ

728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css