whatisthis?

CSS - Animation practice ๋ณธ๋ฌธ

PRACTICE/SELF

CSS - Animation practice

thisisyjin 2022. 3. 1. 11:54

CSS - Animation practice

 

https://www.figma.com/file/k6aekBk53MUKUwVqRHsSVx/Bugless-CSS?node-id=794%3A0

 

 

 

 

๐Ÿ”ป ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ

 

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  font-family: "Mulish", sans-serif;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 100px;
}

.loading-title {
  color: #151b26;
  font-size: 18px;
  line-height: 1.33333333;
  margin-bottom: 20px;
  animation-name: loading-effect;
  animation-duration: 1000ms;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in;
}

.progress-bar {
  position: relative;
  background-color: #e5eaef;
  width: 300px;
  height: 12px;
  border-radius: 100px;
}

.progress-bar-gauge {
  position: absolute;
  top: 0;
  left: 0;
  background-color: #13ce66;
  width: 0;
  height: 12px;
  border-radius: 30px;
  animation-name: loading-progress;
  animation-iteration-count: infinite;
  animation-duration: 2000ms;
  animation-delay: 500ms;
}

@keyframes loading-progress {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes loading-effect {
  from {
    color: #151b26;
  }
  to {
    color: #fff;
  }
}

 

border-radius ์ค˜์„œ ๋™๊ทธ๋ž—๊ฒŒ ๋งŒ๋“ค ๋•Œ,
50%๋ฅผ ์ค„์ˆ˜์žˆ๋Š”๊ฑด ์š”์†Œ๊ฐ€ ์ •์‚ฌ๊ฐํ˜•์ผ๋•Œ๋งŒ ๊ฐ€๋Šฅ.
๋‚˜๋จธ์ง€๋Š” ๊ทธ๋ƒฅ px์„ ํฌ๊ฒŒ ์ค˜์•ผํ•จ.

 

 

 


 

+) ๊ฐ•์˜๋‚ด์šฉ ์ถ”๊ฐ€

 

.progress-bar {
	overflow: hidden;
}

 

์ด๋ ‡๊ฒŒ overflow:hidden์„ ํ•ด์„œ

๊ฒŒ์ด์ง€๊ฐ€ ๋งŒ์•ฝ width๊ฐ€ ๋„˜์–ด๊ฐ€๋„ ์•ˆ๋ณด์ด๊ฒŒ ํ•ด์ค„ ์ˆ˜ ์žˆ์Œ.

 

 

 

 

** ํƒ€์ดํ‹€ ๊ธ€์ž ๊นœ๋นก์ด๊ฒŒ ํ•˜๊ธฐ

 

- ๋‚˜๋Š” color: #fff๋กœ ๋ฐ”๋€Œ๊ฒŒ ํ–ˆ๋Š”๋ฐ,

์—ฌ๊ธฐ์„œ๋Š” ๊ทธ๋ƒฅ ํˆฌ๋ช…๋„(opacity)๋ฅผ ์ค˜์„œ

1(๋ถˆํˆฌ๋ช…) -> 0(ํˆฌ๋ช…)ํ•˜๊ฒŒ ํ•ด์ฃผ์—ˆ๋‹ค.

 

 

@keyframes flicker {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

 

 

+) animation-direction : alternate๋ฅผ  ์ค˜์„œ ์ข€๋” ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ.

    animation-direction: alternate;
alternate
์• ๋‹ˆ๋ฉ”์ด์…˜์€ ๋งค ์‚ฌ์ดํด๋งˆ๋‹ค ๊ฐ ์ฃผ๊ธฐ์˜ ๋ฐฉํ–ฅ์„ ๋’ค์ง‘์œผ๋ฉฐ, ์ฒซ ๋ฒˆ์งธ ๋ฐ˜๋ณต์€ ์ •๋ฐฉํ–ฅ์œผ๋กœ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค.
์‚ฌ์ดํด์ด ์ง์ˆ˜์ธ์ง€ ํ™€์ˆ˜์ธ์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ์นด์šดํŠธ๊ฐ€ ํ•˜๋‚˜์—์„œ ์‹œ์ž‘๋ฉ๋‹ˆ๋‹ค.

 

 

+) ๋กœ๋”ฉ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ˆ˜์ •

 

@keyframes loading-progress {
  0% {
    width: 0;
    opacity: 1;
  }

  80% {
    width: 100%;
    opacity: 1;
  }
  
  100% {
    width: 100%;
    opacity: 0;
  }
}

 

 

 

 

๐Ÿ”ป(์ˆ˜์ •) ์ „์ฒด ์ฝ”๋“œ

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  font-family: "Mulish", sans-serif;
  background-color: #fafafa;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 100px;
  background-color: #fff;
}

.loading-title {
  color: #151b26;
  font-size: 18px;
  line-height: 1.33333333;
  margin-bottom: 20px;
  animation-name: flicker;
  animation-duration: 1600ms;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.progress-bar {
  position: relative;
  background-color: #e5eaef;
  width: 300px;
  height: 12px;
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-gauge {
  position: absolute;
  top: 0;
  left: 0;
  background-color: #13ce66;
  width: 0;
  height: 12px;
  border-radius: 30px;
  animation-name: loading-progress;
  animation-iteration-count: infinite;
  animation-duration: 2000ms;
  animation-timing-function: ease-out;
}

@keyframes loading-progress {
  0% {
    width: 0;
    opacity: 1;
  }

  80% {
    width: 100%;
    opacity: 1;
  }
  100% {
    width: 100%;
    opacity: 0;
  }
}

@keyframes flicker {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

 


ref lecture.