λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
CSS

[CSS] μ •μ‚¬κ°ν˜•μ΄ νšŒμ „ν•˜λŠ” μ• λ‹ˆλ©”μ΄μ…˜ λ§Œλ“€κΈ°

by 코딩곡책 2022. 8. 29.
λ°˜μ‘ν˜•

μ •μ‚¬κ°ν˜•μ΄ νšŒμ „ν•˜λŠ” μ• λ‹ˆλ©”μ΄μ…˜ λ§Œλ“€κΈ°β¬œ

이번 ν¬μŠ€νŒ…μ—μ„œλŠ” μ •μ‚¬κ°ν˜•μ΄ μ‹œκ³„λ°©ν–₯으둜 계속 λŒμ•„κ°€λŠ” κ°„λ‹¨ν•œ μ• λ‹ˆλ©”μ΄μ…˜μ„ λ§Œλ“€μ–΄λ³΄λ„λ‘ ν•˜κ² λ‹€.

HTML μ½”λ“œ

HTML μ½”λ“œλŠ” 맀우 κ°„λ‹¨ν•˜λ‹€. box ν΄λž˜μŠ€κ°’μ„ 가진 div만 λ„£λŠ”λ‹€.

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

CSS μ½”λ“œ

linear-gradient둜 κ·ΈλΌλ””μ–ΈνŠΈ 효과 배경을 μ‚¬μš©ν•  수 있으며 position 속성과 animation, @keyframes 등을 잘 ν™œμš©ν•˜μ—¬ μ• λ‹ˆλ©”μ΄μ…˜μ„ μ™„μ„±μ‹œν‚¬ 수 μžˆλ‹€.

body {
    height: 100vh;
    background-image: linear-gradient(to top, goldenrod, darkkhaki)
  }
  
  .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: khaki;
    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);
    }
  }

κ²°κ³Όλ¬Ό

왠지 이거 λ³΄λ‹ˆκΉŒ νŒ¬μΌ€μ΄ν¬κ°€ λ– μ˜€λ₯΄μ§€ μ•Šλ‚˜μš”? πŸ₯ž

λ°˜μ‘ν˜•

λŒ“κΈ€


Reference Book

JavaScript
HTML
CSS
κ΄‘κ³  μ€€λΉ„μ€‘μž…λ‹ˆλ‹€.