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

[CSS] ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹ค์Šต : ๋กœ๋”ฉ

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

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

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


#1. HTML

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

<div class="loading">
  <span class="circle1"></span>
  <span class="circle2"></span>
</div>

#2. CSS

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

body {
  height: 100vh;
  background-image: linear-gradient(-60deg, plum 0%, skyblue 100%); /* ์™ผ์ชฝ ์•„๋ž˜๋ถ€ํ„ฐ ๊ทธ๋ผ๋””์–ธํŠธ ์‹œ์ž‘ */
}

.loading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 150px;
/*   background: #000; */
/*  ์‹œ์ž‘์€ ๋น ๋ฅด๊ฒŒ ๋งˆ์ง€๋ง‰์€ ์ฒœ์ฒœํžˆ  */
  animation: loading 1s ease infinite;
}

.loading .circle1 {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
}
.loading .circle2 {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  margin-top: 110px;
}

@keyframes loading {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100%{
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

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

728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css