Chris Rutledge Logo

Simple CSS Skeleton Loader

Posted: 3/1/21

Buy Now

Code Resource

      
        

HTML

<figure class="phone"> <div class="phone__card"> <div class="phone__skeleton__block__top"></div> <div class="phone__skeleton__block__bottom"></div> <div class="phone__skeleton"></div> <div class="phone__skeleton"></div> <div class="phone__skeleton"></div> <div class="phone__skeleton"></div> <div class="phone__skeleton"></div> </div> <div class="phone__button">Buy Now</div> </figure>

CSS

.phone { width: 264px; height: 533px; padding: 8px; border-radius: 36px; box-shadow: 0 50px 100px -20px rgb(50 50 93/ 25%), 0 30px 60px -30px rgb(0 0 0 / 30%), inset 0 -2px 6px 0 rgb(10 37 65 / 30%); overflow: hidden; display: flex; flex-direction: column; justify-content: center; position: absolute; top: 10%; left: 50%; transform: translate(-60%, -10%); } .phone__card { display: grid; gap: 0.6rem; padding: 0.8rem; border: 0.1rem solid #d9d9df; border-radius: 0.2rem; margin: 0 0.8rem 0.6rem 0.8rem; } .phone__skeleton { width: 100%; height: 0.5rem; column-count: 2; border-radius: 0.2rem; background-image: linear-gradient( 90deg, #d9d9df 0px, #f0f0f5 20px, #d9d9df 100px ); background-size: 600px; animation: skeleton-loading 2s infinite ease-out; } .phone__skeleton__block__top { width: 50%; height: 1.3rem; border-radius: 0.2rem; background-image: linear-gradient( 90deg, #d9d9df 0px, #f0f0f5 20px, #d9d9df 100px ); background-size: 600px; animation: skeleton-loading 2s infinite ease-out; } .phone__skeleton__block__bottom { width: 60%; height: 0.9rem; border-radius: 0.2rem; background-image: linear-gradient( 90deg, #d9d9df 0px, #f0f0f5 20px, #d9d9df 100px ); background-size: 600px; animation: skeleton-loading 2s infinite ease-out; } @keyframes skeleton-loading { 0% { background-position: -100px; } 40%, 100% { background-position: 200px; } } .phone__button { background: #07070e; color: #f6f9fc; display: grid; place-items: center; padding: 0.7rem; font-size: 0.8rem; user-select: none; border-radius: 0.2rem; margin: 0 0.8rem; animation: skeleton-loading 2s infinite ease-out; } .phone__button:hover { background: #3c3c3cd6; cursor: pointer; transition: 0.3s; }