Skip to content
Skeleton UI실무 경험

The world's simplest Skeleton UI with only HTML & CSS

1 min readWorkMoved from my Tistory blogRead the Korean original

Today a backend developer at work asked me to make a Skeleton UI as simply as possible, so I built one as quickly as I could.

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    .wrapper {
      width: 20rem;
      border: 1px solid #e4eaef;
      border-radius: 12px;
      overflow: hidden;
    }
    @keyframes loading {
      0% {
        opacity: 1;
      }
      50% {
        opacity: 0.5;
      }
      100% {
        opacity: 1;
      }
    }

    .imgBox {
      height: 207px;
      background: #f7f9fa;
      background-size: 200% 100%;
      animation: loading 2.5s infinite;
    }
    .infoBox {
      padding: 12px;

      > :nth-child(1) {
        width: 100%;
        height: 1.5rem;
        border-radius: 0.5rem;
        background-color: #e4eaef;
        background-size: 200% 100%;
        animation: loading 2.5s infinite;
      }

      > :nth-child(2) {
        margin-top: 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
      }
      .itemBox {
        display: flex;
        gap: 0.5rem;
      }
      .lastItemBox {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .itemIcon {
        width: 1rem;
        height: 1rem;
        border-radius: 0.1rem;
        background-color: #e4eaef;
        background-size: 200% 100%;
        animation: loading 2.5s infinite;
      }
      .itemMent {
        width: 5rem;
        height: 1rem;
        border-radius: 0.5rem;
        background-color: #e4eaef;
        background-size: 200% 100%;
        animation: loading 2.5s infinite;
      }

      .priceBox {
        width: 6rem;
        height: 1.8rem;
        border-radius: 0.5rem;
        background: #e4eaef;
        border-radius: 1rem;
        background-size: 200% 100%;
        animation: loading 2.5s infinite;
      }
    }
  </style>
  <body>
    <div class="wrapper">
      <div class="imgBox"></div>
      <div class="infoBox">
        <div></div>
        <div>
          <div class="itemBox">
            <div class="itemIcon"></div>
            <div class="itemMent"></div>
          </div>
          <div class="itemBox">
            <div class="itemIcon"></div>
            <div class="itemMent"></div>
          </div>
          <div class="itemBox">
            <div class="itemIcon"></div>
            <div class="itemMent"></div>
          </div>
          <div class="lastItemBox">
            <div class="itemBox">
              <div class="itemIcon"></div>
              <div class="itemMent"></div>
            </div>
            <div class="priceBox"></div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

The key here is that it is implemented with opacity in @keyframes.

If you take the code as is and run it, you will see a shimmering effect as the opacity changes.

  • #opacity
  • #easiest
  • #skeleton UI

More in Work