🦁_21.11.09(1) TIL

BoriΒ·2021λ…„ 11μ›” 9일
1
post-thumbnail

21λ…„ 11μ›” 09일(1)

πŸ“Ž λ ˆμ΄μ•„μ›ƒ κ΅¬ν˜„ ν”„λ‘œμ νŠΈ_1

μ •κΈ€ μ‹œλ„€λ§ˆ - μ†ŒμŠ€μ½”λ“œ 보기

πŸ“ CSS

πŸ“Ž SVG

  • ν™•μž₯ κ°€λŠ₯ν•œ 벑터 κ·Έλž˜ν”½(Scalable Vector Graphics)으둜 HTML 기반의 2차원 κ·Έλž˜ν”½
  • HTML νƒœκ·Έμ˜ μ§‘ν•©μœΌλ‘œ 이루어져 μžˆμ–΄ CSS와 JavaScript둜 컨트둀이 κ°€λŠ₯

SVG μž₯점

  • 아무리 ν™•λŒ€λ₯Ό 해도 이미지가 깨지지 μ•ŠλŠ”λ‹€.
    => 벑터 κ·Έλž˜ν”½μ΄λ―€λ‘œ
  • μ΄λ―Έμ§€μ˜ 크기λ₯Ό ν‚€μ›Œλ„ μš©λŸ‰μ΄ λŠ˜μ–΄λ‚˜μ§€ μ•ŠλŠ”λ‹€.

SVG 단점

  • λ‹¨μˆœν•œ λͺ¨μ–‘μΌμˆ˜λ‘ 효율이 μ’‹λ‹€.
    => μ½”λ“œλ‘œ 이루어진 μ΄λ―Έμ§€μ΄λ―€λ‘œ λ³΅μž‘ν•œ μ΄λ―Έμ§€μΌμˆ˜λ‘ 파일의 크기 컀진닀.
    => λ³΅μž‘ν•œ 이미지λ₯Ό SVG둜 ν‘œν˜„ν•˜λ©΄ 였히렀 μš©λŸ‰μ΄ 컀져 μ—­νš¨κ³Όκ°€ λ‚  수 μžˆλ‹€.

HTML에 SVGλ₯Ό μ μš©ν•˜λŠ” 방법

[ 예제 이미지 - frog.svg ]

  • <img>둜 μ‚¬μš© : src="" μ†μ„±κ°’μœΌλ‘œ SVG 파일 μ—°κ²°
    <img src="frog.svg" alt="">
  • CSS background둜 μ‚¬μš© : background-img μ†μ„±κ°’μœΌλ‘œ SVG 파일 μ—°κ²°
    .cont-svg {
      width: 100vw;
      height: 100vh;
      background: url(frog.svg) no-repeat 0 0;
      background-size: contain;
    }
  • 인라인으둜 κ΅¬ν˜„ : SVG 파일의 μ½”λ“œλ₯Ό κ·ΈλŒ€λ‘œ HTML μ½”λ“œ μ•ˆμ—μ„œ μ‚¬μš©
<svg width="624" height="465" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path
        d="m446.529 308.502 79.386-37.479c-37.824-34.863-111.48-58.521-196.146-58.521-123.264 0-223.191 50.142-223.191 112.002 0 61.857 99.927 112.002 223.191 112.002 94.674 0 175.575-29.586 208.011-71.334l-91.251-56.67Z"
        fill="#00A249" />
  <path
        d="m446.529 308.502 79.386-37.479c-37.824-34.863-111.48-58.521-196.146-58.521-123.264 0-223.191 50.142-223.191 112.002 0 61.857 99.927 112.002 223.191 112.002 94.674 0 175.575-29.586 208.011-71.334l-91.251-56.67Z"
        stroke="#1A1919" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M427.656 312.627c1.5-16.5-15.081-29.259-34.239-28.641-3.018-7.002-16.917-33.714-20.511-40.359l-57.876-1.365-57.876 1.365c-3.594 6.645-17.493 33.357-20.511 40.359-19.155-.618-35.739 12.141-34.239 28.641 2.091 22.977 11.352 19.851 29.001 28.5-10.416 4.188-26.001 11.499-26.001 11.499l23.499 1.5-3.6 10.917s48.228-24.042 69.6-24.417c6.678-.12 14.595-.759 20.127-1.287 5.535.528 13.452 1.167 20.127 1.287 21.372.375 69.6 24.417 69.6 24.417l-3.6-10.917 23.499-1.5s-15.582-7.311-26.001-11.499c17.652-8.649 26.913-5.523 29.001-28.5"
        fill="#89C140" />
  <path
        d="M427.656 312.627c1.5-16.5-15.081-29.259-34.239-28.641-3.018-7.002-16.917-33.714-20.511-40.359l-57.876-1.365-57.876 1.365c-3.594 6.645-17.493 33.357-20.511 40.359-19.155-.618-35.739 12.141-34.239 28.641 2.091 22.977 11.352 19.851 29.001 28.5-10.416 4.188-26.001 11.499-26.001 11.499l23.499 1.5-3.6 10.917s48.228-24.042 69.6-24.417c6.678-.12 14.595-.759 20.127-1.287 5.535.528 13.452 1.167 20.127 1.287 21.372.375 69.6 24.417 69.6 24.417l-3.6-10.917 23.499-1.5s-15.582-7.311-26.001-11.499c17.652-8.649 26.913-5.523 29.001-28.5v0Z"
        stroke="#1A1919" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M178.524 135.165c-1.785-20.466 10.644-46.113 54.507-48.666 29.568-1.722 41.121 15.627 47.496 31.002l20.502-1.002c3.669-19.797 19.497-38.874 60.372-36.624 29.592 1.629 39.051 26.535 42.123 39.126 3.591 14.7 2.502 20.499 6.252 28.749 4.725 10.398 30.009 13.749 25.755 55.749-7.821 77.217-249.189 72.888-270.255 23.001-14.25-33.75 6.753-49.5 14.253-59.25l-1.005-32.085Z"
        fill="#8FC23F" />
  <path
        d="M178.524 135.165c-1.785-20.466 10.644-46.113 54.507-48.666 29.568-1.722 41.121 15.627 47.496 31.002l20.502-1.002c3.669-19.797 19.497-38.874 60.372-36.624 29.592 1.629 39.051 26.535 42.123 39.126 3.591 14.7 2.502 20.499 6.252 28.749 4.725 10.398 30.009 13.749 25.755 55.749-7.821 77.217-249.189 72.888-270.255 23.001-14.25-33.75 6.753-49.5 14.253-59.25l-1.005-32.085Z"
        stroke="#1A1919" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M270.528 291c10.404-10.239 30.216-15.207 44.25-15 19.386.279 42.096 6.012 53.394 22.404 9.006 13.071-12.129 39.6-24.057 40.347-18.759 1.167-37.395 2.637-56.139 3.582-11.889.597-27.174-41.76-17.448-51.333Z"
        fill="#FFFFFE" />
  <path
        d="M270.528 291c10.404-10.239 30.216-15.207 44.25-15 19.386.279 42.096 6.012 53.394 22.404 9.006 13.071-12.129 39.6-24.057 40.347-18.759 1.167-37.395 2.637-56.139 3.582-11.889.597-27.174-41.76-17.448-51.333Z"
        stroke="#1A1919" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M373.41 179.388c.219 7.863-32.733 25.458-73.881 26.613-41.139 1.155-74.886-14.568-75.108-22.434-.219-7.863 148.767-12.042 148.989-4.179"
        fill="#E88194" />
  <path
        d="M373.41 179.388c.219 7.863-32.733 25.458-73.881 26.613-41.139 1.155-74.886-14.568-75.108-22.434-.219-7.863 148.767-12.042 148.989-4.179v0Z"
        stroke="#1A1919" stroke-width="7.425" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M213.528 195.375c0 8.49-7.218 15.375-16.125 15.375s-16.125-6.885-16.125-15.375c0-8.493 7.218-15.375 16.125-15.375s16.125 6.882 16.125 15.375Zm205.5-7.5c0 8.49-7.218 15.375-16.125 15.375-8.904 0-16.125-6.885-16.125-15.375 0-8.493 7.221-15.375 16.125-15.375 8.907 0 16.125 6.882 16.125 15.375Z"
        fill="#E88194" />
  <path
        d="M428.892 37.503c0 8.88-5.76 16.077-12.861 16.077-7.104 0-12.864-7.197-12.864-16.077 0-8.88 13.398-31.086 13.398-31.086s12.327 22.206 12.327 31.086"
        fill="#C9E8F2" />
  <path
        d="M428.892 37.503c0 8.88-5.76 16.077-12.861 16.077-7.104 0-12.864-7.197-12.864-16.077 0-8.88 13.398-31.086 13.398-31.086s12.327 22.206 12.327 31.086v0Z"
        stroke="#1A1919" stroke-width="7.074" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M518.526 189.084c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083"
        fill="#C9E8F2" />
  <path
        d="M518.526 189.084c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083v0Z"
        stroke="#1A1919" stroke-width="7.074" stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M116.526 167.085c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083"
        fill="#C9E8F2" />
  <path
        d="M116.526 167.085c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083v0Z"
        stroke="#1A1919" stroke-width="7.074" stroke-linecap="round" stroke-linejoin="round" />
  <path d="M529.278 289.875C515.403 306 530.529 324.501 552.528 324" stroke="#1A1919" stroke-width="5.844"
        stroke-linecap="round" stroke-linejoin="round" />
  <path d="M609.528 283.002c16.125 6.498 9.999 20.964 3.999 25.998" stroke="#1A1919" stroke-width="6.48"
        stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="M581.421 283.671c7.503 1.605 12.891 5.862 13.089 11.058.171 4.5-2.232 10.146-9.381 11.025m-22.098 4.245c-9.375.375-15.096-5.766-15.378-11.124-.375-7.125 4.284-12.237 11.406-14.463l3.972 25.587Z"
        stroke="#1A1919" stroke-width="6.309" stroke-linecap="round" stroke-linejoin="round" />
  <path d="M506.028 36v108m63.501 150.501V120v174.501Z" stroke="#1A1919" stroke-width="6.48"
        stroke-linecap="round" stroke-linejoin="round" />
  <path d="M573.03 324.999c9.378-.018 16.419-.681 24.501-5.499" stroke="#1A1919" stroke-width="5.844"
        stroke-linecap="round" stroke-linejoin="round" />
  <path
        d="m442.77 254.502-28.002 18.999m-233.997-3.999L208.77 280.5l-27.999-10.998Zm-38.001 48h39.999-39.999Zm99.999 60.999-25.998 23.001 25.998-23.001Zm81 3 6.999 39-6.999-39Zm77.001 0 33.999 24-33.999-24Z"
        stroke="#1A1919" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" />
  <path d="M254 136c0 16.016-13.208 29-29.5 29S195 152.016 195 136s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
        fill="#fff" />
  <path d="M254 136c0 16.016-13.208 29-29.5 29S195 152.016 195 136s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
        stroke="#000" />
  <ellipse cx="224.5" cy="136" rx="12.5" ry="12" fill="#000" />
  <path d="M383 129c0 16.016-13.208 29-29.5 29S324 145.016 324 129s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
        fill="#fff" />
  <path d="M383 129c0 16.016-13.208 29-29.5 29S324 145.016 324 129s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
        stroke="#000" />
  <ellipse class="eye-right" cx="353.5" cy="129" rx="12.5" ry="12" fill="#000" />
</svg>

CSS μ μš©ν•΄λ³΄κΈ° - μœ™ν¬ν•˜λŠ” 개ꡬ리

/** 적용 μˆœμ„œ **/
/* 1. 였λ₯Έμͺ½ λˆˆμ„ κ·Έλ¦¬λŠ” ellipses μš”μ†Œμ— class="eye-right" 클래슀λ₯Ό μΆ”κ°€ν•©λ‹ˆλ‹€. */
/* 2. ν΄λž˜μŠ€μ— μ• λ‹ˆλ©”μ΄μ…˜ 속성을 μž‘μ„±ν•΄μ€λ‹ˆλ‹€. */
/* μ΄λ•Œ transform-origin 으둜 쀑심좕을 μ„€μ •ν•΄μ•Όν•©λ‹ˆλ‹€. μ’Œν‘œλŠ” ellipses μš”μ†Œμ•ˆμ˜ cx="353.5" cy="129" μž…λ‹ˆλ‹€. */

.eye-right {
    animation-duration: 0.5s;
    animation-name: blink;
    animation-direction: alternate;
    animation-iteration-count: infinite;
    transform-origin: 353.5px 129px;
}

@keyframes blink {
    to {
        transform: scaleY(0.1);
    }
}

μ‹€μŠ΅

<!DOCTYPE html>
<html lang="ko">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>New Colored Frog</title>
    <style>
      body {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 1000px;
      }

      .container {
        position: relative;
      }

      .umbrella {
        position: absolute;
        top: -135px;
        left: 60px;
        z-index: -1;
        transform: rotate(-10deg);
      }

      .umbrella-top {
        overflow: hidden;
        position: relative;
        width: 400px;
        height: 180px;
        border-radius: 400px 400px 0 0;
        border: 10px solid #000;
        background-color: #998ceb;
      }

      .umbrella-bottom {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
      }

      .umbrella-bottom__ver {
        width: 10px;
        height: 150px;
        background-color: #000;
      }

      .umbrella-bottom__round {
        position: absolute;
        bottom: -35px;
        left: -60px;
        width: 50px;
        height: 25px;
        border: 10px solid #000;
        border-radius: 50px 50px 0 0;
        background-color: #fff;
        transform: rotate(180deg);
      }

      .umbrella-bottom__round::after {
        content: "";
        display: block;
        position: absolute;
        bottom: -10px;
        width: 50px;
        height: 10px;
        /* border-radius: 50px 50px 0 0; */
        background-color: #fff;
      }

      .wink-right {
        position: absolute;
        top: 130px;
        right: 290px;
      }

      .wink-line {
        position: absolute;
        left: 0;
        width: 40px;
        height: 5px;
        border-radius: 10px;
        background-color: #000;
      }

      .wink-line:nth-child(1) {
        top: -10px;
        transform: rotate(-30deg);
      }

      .wink-line:nth-child(3) {
        top: 10px;
        transform: rotate(30deg);
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="umbrella">
        <div class="umbrella-top"></div>
        <div class="umbrella-bottom">
          <div class="umbrella-bottom__ver"></div>
          <div class="umbrella-bottom__round"></div>
        </div>
      </div>
      <svg
        width="624"
        height="465"
        fill="none"
        xmlns="http://www.w3.org/2000/svg"
      >
        <path
          d="m446.529 308.502 79.386-37.479c-37.824-34.863-111.48-58.521-196.146-58.521-123.264 0-223.191 50.142-223.191 112.002 0 61.857 99.927 112.002 223.191 112.002 94.674 0 175.575-29.586 208.011-71.334l-91.251-56.67Z"
          fill="#00A249"
        />
        <path
          d="m446.529 308.502 79.386-37.479c-37.824-34.863-111.48-58.521-196.146-58.521-123.264 0-223.191 50.142-223.191 112.002 0 61.857 99.927 112.002 223.191 112.002 94.674 0 175.575-29.586 208.011-71.334l-91.251-56.67Z"
          stroke="#1A1919"
          stroke-width="9"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M427.656 312.627c1.5-16.5-15.081-29.259-34.239-28.641-3.018-7.002-16.917-33.714-20.511-40.359l-57.876-1.365-57.876 1.365c-3.594 6.645-17.493 33.357-20.511 40.359-19.155-.618-35.739 12.141-34.239 28.641 2.091 22.977 11.352 19.851 29.001 28.5-10.416 4.188-26.001 11.499-26.001 11.499l23.499 1.5-3.6 10.917s48.228-24.042 69.6-24.417c6.678-.12 14.595-.759 20.127-1.287 5.535.528 13.452 1.167 20.127 1.287 21.372.375 69.6 24.417 69.6 24.417l-3.6-10.917 23.499-1.5s-15.582-7.311-26.001-11.499c17.652-8.649 26.913-5.523 29.001-28.5"
          fill="#B4FE98"
        />
        <path
          d="M427.656 312.627c1.5-16.5-15.081-29.259-34.239-28.641-3.018-7.002-16.917-33.714-20.511-40.359l-57.876-1.365-57.876 1.365c-3.594 6.645-17.493 33.357-20.511 40.359-19.155-.618-35.739 12.141-34.239 28.641 2.091 22.977 11.352 19.851 29.001 28.5-10.416 4.188-26.001 11.499-26.001 11.499l23.499 1.5-3.6 10.917s48.228-24.042 69.6-24.417c6.678-.12 14.595-.759 20.127-1.287 5.535.528 13.452 1.167 20.127 1.287 21.372.375 69.6 24.417 69.6 24.417l-3.6-10.917 23.499-1.5s-15.582-7.311-26.001-11.499c17.652-8.649 26.913-5.523 29.001-28.5v0Z"
          stroke="#1A1919"
          stroke-width="9"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M178.524 135.165c-1.785-20.466 10.644-46.113 54.507-48.666 29.568-1.722 41.121 15.627 47.496 31.002l20.502-1.002c3.669-19.797 19.497-38.874 60.372-36.624 29.592 1.629 39.051 26.535 42.123 39.126 3.591 14.7 2.502 20.499 6.252 28.749 4.725 10.398 30.009 13.749 25.755 55.749-7.821 77.217-249.189 72.888-270.255 23.001-14.25-33.75 6.753-49.5 14.253-59.25l-1.005-32.085Z"
          fill="#B4FE98"
        />
        <path
          d="M178.524 135.165c-1.785-20.466 10.644-46.113 54.507-48.666 29.568-1.722 41.121 15.627 47.496 31.002l20.502-1.002c3.669-19.797 19.497-38.874 60.372-36.624 29.592 1.629 39.051 26.535 42.123 39.126 3.591 14.7 2.502 20.499 6.252 28.749 4.725 10.398 30.009 13.749 25.755 55.749-7.821 77.217-249.189 72.888-270.255 23.001-14.25-33.75 6.753-49.5 14.253-59.25l-1.005-32.085Z"
          stroke="#1A1919"
          stroke-width="9"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M270.528 291c10.404-10.239 30.216-15.207 44.25-15 19.386.279 42.096 6.012 53.394 22.404 9.006 13.071-12.129 39.6-24.057 40.347-18.759 1.167-37.395 2.637-56.139 3.582-11.889.597-27.174-41.76-17.448-51.333Z"
          fill="#FFFFFE"
        />
        <path
          d="M270.528 291c10.404-10.239 30.216-15.207 44.25-15 19.386.279 42.096 6.012 53.394 22.404 9.006 13.071-12.129 39.6-24.057 40.347-18.759 1.167-37.395 2.637-56.139 3.582-11.889.597-27.174-41.76-17.448-51.333Z"
          stroke="#1A1919"
          stroke-width="9"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M373.41 179.388c.219 7.863-32.733 25.458-73.881 26.613-41.139 1.155-74.886-14.568-75.108-22.434-.219-7.863 148.767-12.042 148.989-4.179"
          fill="#E88194"
        />
        <path
          d="M373.41 179.388c.219 7.863-32.733 25.458-73.881 26.613-41.139 1.155-74.886-14.568-75.108-22.434-.219-7.863 148.767-12.042 148.989-4.179v0Z"
          stroke="#1A1919"
          stroke-width="7.425"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M213.528 195.375c0 8.49-7.218 15.375-16.125 15.375s-16.125-6.885-16.125-15.375c0-8.493 7.218-15.375 16.125-15.375s16.125 6.882 16.125 15.375Zm205.5-7.5c0 8.49-7.218 15.375-16.125 15.375-8.904 0-16.125-6.885-16.125-15.375 0-8.493 7.221-15.375 16.125-15.375 8.907 0 16.125 6.882 16.125 15.375Z"
          fill="#E88194"
        />
        <path
          d="M428.892 37.503c0 8.88-5.76 16.077-12.861 16.077-7.104 0-12.864-7.197-12.864-16.077 0-8.88 13.398-31.086 13.398-31.086s12.327 22.206 12.327 31.086"
          fill="#C9E8F2"
        />
        <path
          d="M428.892 37.503c0 8.88-5.76 16.077-12.861 16.077-7.104 0-12.864-7.197-12.864-16.077 0-8.88 13.398-31.086 13.398-31.086s12.327 22.206 12.327 31.086v0Z"
          stroke="#1A1919"
          stroke-width="7.074"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M518.526 189.084c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083"
          fill="#C9E8F2"
        />
        <path
          d="M518.526 189.084c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083v0Z"
          stroke="#1A1919"
          stroke-width="7.074"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M116.526 167.085c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083"
          fill="#C9E8F2"
        />
        <path
          d="M116.526 167.085c0 8.88-5.76 16.08-12.861 16.08-7.104 0-12.864-7.2-12.864-16.08 0-8.88 13.398-31.083 13.398-31.083s12.327 22.203 12.327 31.083v0Z"
          stroke="#1A1919"
          stroke-width="7.074"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M529.278 289.875C515.403 306 530.529 324.501 552.528 324"
          stroke="#1A1919"
          stroke-width="5.844"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M609.528 283.002c16.125 6.498 9.999 20.964 3.999 25.998"
          stroke="#1A1919"
          stroke-width="6.48"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M581.421 283.671c7.503 1.605 12.891 5.862 13.089 11.058.171 4.5-2.232 10.146-9.381 11.025m-22.098 4.245c-9.375.375-15.096-5.766-15.378-11.124-.375-7.125 4.284-12.237 11.406-14.463l3.972 25.587Z"
          stroke="#1A1919"
          stroke-width="6.309"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M506.028 36v108m63.501 150.501V120v174.501Z"
          stroke="#1A1919"
          stroke-width="6.48"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="M573.03 324.999c9.378-.018 16.419-.681 24.501-5.499"
          stroke="#1A1919"
          stroke-width="5.844"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <path
          d="m442.77 254.502-28.002 18.999m-233.997-3.999L208.77 280.5l-27.999-10.998Zm-38.001 48h39.999-39.999Zm99.999 60.999-25.998 23.001 25.998-23.001Zm81 3 6.999 39-6.999-39Zm77.001 0 33.999 24-33.999-24Z"
          stroke="#1A1919"
          stroke-width="6"
          stroke-linecap="round"
          stroke-linejoin="round"
        />
        <!-- μ™Όμͺ½ 눈 -->
        <path
          d="M254 136c0 16.016-13.208 29-29.5 29S195 152.016 195 136s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
          fill="#fff"
        />
        <path
          d="M254 136c0 16.016-13.208 29-29.5 29S195 152.016 195 136s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
          stroke="#000"
          stroke-width="5.844"
        />
        <ellipse cx="224.5" cy="136" rx="12.5" ry="12" fill="#000" />
        <!-- 였λ₯Έμͺ½ 눈 -->
        <!-- <path
          d="M383 129c0 16.016-13.208 29-29.5 29S324 145.016 324 129s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
          fill="#fff"
        />
        <path
          d="M383 129c0 16.016-13.208 29-29.5 29S324 145.016 324 129s13.208-29 29.5-29 29.5 12.984 29.5 29Z"
          stroke="#000"
          stroke-width="5.844"
        />
        <ellipse
          class="eye-right"
          cx="353.5"
          cy="129"
          rx="12.5"
          ry="12"
          fill="#000"
        /> -->
        <div class="wink-right">
          <div class="wink-line"></div>
          <div class="wink-line"></div>
          <div class="wink-line"></div>
        </div>
      </svg>
    </div>
  </body>
</html>

πŸ“Ž μƒν˜Έ μž‘μš©μ„ μœ„ν•œ κ°€μƒν΄λž˜μŠ€

:hover

  • μ‚¬μš©μžκ°€ 마우슀λ₯Ό μš”μ†Œ μœ„μ— μ˜¬λ Έμ„ λ–„ 적용
  • 슀마트폰, νƒœλΈ”λ¦Ώ λ₯˜μ˜ ν„°μΉ˜μŠ€ν¬λ¦° κΈ°κΈ°μ—μ„œλŠ” μ‚¬μš©μžμ˜ 손가락이 hoverλ˜λŠ” μ‹œμ μ„ μ•Œ 수 μ—†κΈ° λ•Œλ¬Έμ— ν˜„μž¬λŠ” μ‚¬μš©λΉˆλ„κ°€ 쀄어듀고 μžˆλ‹€.

:active

  • μ‚¬μš©μžκ°€ μš”μ†Œλ₯Ό μ‹€ν–‰ν•  λ•Œ 적용
    => λ²„νŠΌμ„ λˆ„λ₯΄κ±°λ‚˜ 링크λ₯Ό 클릭할 λ•Œ

:focus

  • μš”μ†Œμ— ν¬μ»€μŠ€κ°€ μžˆμ„ λ•Œ 적용
    => 클릭할 수 μžˆλŠ” μš”μ†Œλ‚˜ 폼 컨트둀(input, select λ“±)κ³Ό 같이 μƒν˜Έμž‘μš© ν•  수 μžˆλŠ” λͺ¨λ“  μš”μ†Œμ—μ„œ focus κ°€λŠ₯

πŸ“Ž CSS transition

  • transition : CSS 속성값이 λ³€ν•  λ•Œ, κ°’μ˜ λ³€ν™”κ°€ 일정 μ‹œκ°„μ— 걸쳐 μΌμ–΄λ‚˜λ„λ‘ ν•˜λŠ” 것

    [좜처: Webanimation 1λΆ€ css Animation]

  • property : μ–΄λ–€ 속성에 transition효과λ₯Ό 쀄 지 μ„€μ •

    속성값섀λͺ…
    allκΈ°λ³Έκ°’, λͺ¨λ“  속성에 transition νš¨κ³Όκ°€ λ‚˜νƒ€λ‚¨
    nonetransition 효과λ₯Ό 받지 λͺ»ν•¨
    propertytransition 효과λ₯Ό μ μš©ν•˜κ³  싢은 CSS 속성을 μ„€μ •ν•˜μ—¬ μ§€μ •λœ μ†μ„±μ—λ§Œ transition이 λ‚˜νƒ€λ‚¨
    initialμ†μ„±μ˜ κΈ°λ³Έκ°’μœΌλ‘œ μ„€μ •
    inheritλΆ€λͺ¨ μš”μ†Œμ˜ 속성값을 상속 λ°›μŒ
  • duration : transition이 μΌμ–΄λ‚˜λŠ” μ§€μ†μ‹œκ°„ μ„€μ •

    • λ‹¨μœ„ : s, ms
    • 미지정 μ‹œ, 0sλ₯Ό 의미
      지연없이 λ°”λ‘œtransition이 일어남
  • delay : transition이 일어날 λ•Œ μ–Όλ§ˆλ§ŒνΌ κΈ°λ‹€λ Έλ‹€κ°€ μ‹€ν–‰ν•  지 κ²°μ •

    • λ‹¨μœ„ : s, ms
    • 미지정 μ‹œ, 0sλ₯Ό 의미
      transition의 νš¨κ³Όκ°€ λ‚˜νƒ€λ‚˜μ§€ μ•ŠμŒ
  • timing - function : transition의 진행 속도 μ„€μ •

    속성값섀λͺ…
    linearμ²˜μŒλΆ€ν„° λκΉŒμ§€ μΌμ •ν•œ 속도
    = cubic-bezier(0, 0, 1, 1)
    easeκΈ°λ³Έκ°’, 천천히 μ‹œμž‘ / λΉ λ₯΄κ²Œ 진행 / 천천히 끝
    = cubic-bezier(0.25, 0.1, 0.25, 0.1)
    ease-in천천히 μ‹œμž‘
    = cubic-bezier(0.42, 0, 1, 1)
    ease-out천천히 끝
    = cubic-bezier(0, 0, 0.58, 1)
    ease-in-out천천히 μ‹œμž‘, 천천히 끝
    = cubic-bezier(0.42, 0, 0.58, 1)
    step-startμ‹œμž‘ν•˜λŠ” μ‹œμ μ— μŠ€ν…μ„ λŠμ–΄μ€Œ
    = steps(1, start)
    step-endλλ‚˜λŠ” μ‹œμ μ— μŠ€ν…μ„ λŠμ–΄μ€Œ
    =steps(1, end)
    steps(int, start/end)int = μ •μˆ˜, start/end
    int만큼 μ‹œμž‘μ΄λ‚˜ λλ‚˜λŠ” μ‹œμ μ— μŠ€ν…μ„ λŠμ–΄μ€Œ
    cubic-bezier(n, n, n, n)베지어 곑선에 μ›ν•˜λŠ” 컨트둀 포인트 직접 μ„€μ •
    initialμ†μ„±μ˜ κΈ°λ³Έκ°’μœΌλ‘œ 적용
    inheritλΆ€λͺ¨μ˜ 영ν–₯을 λ°›μ•„ 적용

πŸ“Ž CSS transform

  • transform : Objectλ₯Ό μ—¬λŸ¬ ν˜•νƒœλ‘œ λ³€ν˜•ν•  λ•Œ μ‚¬μš©ν•˜λŠ” 속성, transitionκ³Ό ν•¨κ»˜ μ‚¬μš©ν•˜λ©΄ 더 큰 효과λ₯Ό λ‚Ό 수 μžˆλ‹€.

    CSS Transform Playround

scale(sx) / scale(sx ,sy)

ν•œ 개 λ˜λŠ” 두 개의 κ°’μœΌλ‘œ 지정, 각 λ°©ν–₯에 μ μš©ν•  크기λ₯Ό λ‚˜νƒ€λƒ„
= Resizing

  • sx : xμΆ• λ°©ν–₯으둜 크기 적용
  • sy : yμΆ• λ°©ν–₯으둜 크기 적용, μ§€μ •λ˜μ§€ μ•Šμ€ 경우 기본값은 sx와 같은 κ°’μœΌλ‘œ μ μš©λ˜μ–΄ κ· μΌν•œ 배율둜 크기 적용

[좜처: Webanimation 1λΆ€ css Animation]

rotate(a)

κ°λ„λ§ŒνΌ νšŒμ „, μ–‘μˆ˜λŠ” μ‹œκ³„ λ°©ν–₯, μŒμˆ˜λŠ” λ°˜μ‹œκ³„ λ°©ν–₯
= Rotation

  • a : νšŒμ „ 각도
  • λ‹¨μœ„ : deg(degree)

[좜처: Webanimation 1λΆ€ css Animation]

translate()

xμΆ• λ˜λŠ” yμΆ•μœΌλ‘œ 이동
= Moving

  • Single <length-percentage> values : xμΆ• λ°©ν–₯으둜 이동, y좕은 0으둜 μ„€μ •
  • Double <length-percentage> values : xμΆ•κ³Ό yμΆ• λ°©ν–₯으둜 이동
    • λ‹¨μœ„ : px, %
  /* Single <length-percentage> values */
  transform: translate(200px);
  transform: translate(50%);

  /* Double <length-percentage> values */
  transform: translate(100px, 200px);
  transform: translate(100px, 50%);
  transform: translate(30%, 200px);
  transform: translate(30%, 50%);

[좜처: Webanimation 1λΆ€ css Animation]

skew(ax) / skew(ax, ay)

ν•œ 개 λ˜λŠ” 두 개의 κ°’μœΌλ‘œ 지정, 각 λ°©ν–₯의 각도에 따라 μ™œκ³‘(비틀어짐)
= Distortion

  • ax : x좕을 따라 μ™œκ³‘
  • ay : y좕을 따라 μ™œκ³‘, μ§€μ •λ˜μ§€ μ•Šμ€ 경우 기본값은 0
  • λ‹¨μœ„ : deg(degree)

[좜처: Webanimation 1λΆ€ css Animation]

transform-origin

transform이 μ μš©λ˜λŠ” 기쀀점

  • κΈ°λ³Έκ°’ : ν•΄λ‹Ή μš”μ†Œμ˜ 쀑심
  • left, right, top, bottom, center을 μ΄μš©ν•΄ μœ„μΉ˜ μ„€μ • κ°€λŠ₯
  • μˆ«μžκ°’ κ°€λŠ₯
  /* One-value syntax */
  transform-origin: 2px;
  transform-origin: bottom;

  /* x-offset | y-offset */
  transform-origin: 3cm 2px;

  /* x-offset-keyword | y-offset */
  transform-origin: left 2px;

  /* x-offset-keyword | y-offset-keyword */
  transform-origin: right top;

  /* y-offset-keyword | x-offset-keyword */
  transform-origin: top right;

  /* x-offset | y-offset | z-offset */
  transform-origin: 2px 30% 10px;

  /* x-offset-keyword | y-offset | z-offset */
  transform-origin: left 5px -3px;

  /* x-offset-keyword | y-offset-keyword | z-offset */
  transform-origin: right bottom 2cm;

  /* y-offset-keyword | x-offset-keyword | z-offset */
  transform-origin: bottom right 2cm;

  /* Global values */
  transform-origin: inherit;
  transform-origin: initial;
  transform-origin: revert;
  transform-origin: unset;

translate vs position

translate, position λͺ¨λ‘ μ›ν•˜λŠ” μ’Œν‘œλ‘œ μš”μ†Œλ₯Ό 움직일 수 μžˆλ‹€.
κ·Έλ ‡λ‹€λ©΄, μš°λ¦¬λŠ” μ–Έμ œ translate을 μ‚¬μš©ν•˜κ³  position을 μ‚¬μš©ν•΄μ•Ό ν• κΉŒ?

  • 정적인 μ‚¬μ΄νŠΈμ—μ„œ μš”μ†Œμ˜ μœ„μΉ˜λ₯Ό λ‹¨μˆœ λ°°μΉ˜ν•˜λŠ” 경우 => position
  • μ• λ‹ˆλ©”μ΄μ…˜ λ˜λŠ” λ™μ μœΌλ‘œ μš”μ†Œμ˜ μœ„μΉ˜λ₯Ό μ΄λ™ν•΄μ•Όν•˜λŠ” 경우 => translate

πŸ‘‰ 🦁_21.11.09(2) TIL 둜 이동

0개의 λŒ“κΈ€