Skeleton Loading Like YouTube

Skeleton Loading Like YouTube

source code available



Source Code

Copy and Paste On Code Editor




<html lang="en">
<head>
    <meta charset="UTF-8"></meta>
    <meta content="IE=edge" http-equiv="X-UA-Compatible"></meta>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"></meta>
    <title>Document</title>
</head>
<body>
    <style>
        body{
            margin:0px;
        }
        .container{
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;

        }
        .post{
            width: 220px;
            height:80px;

        }
        .post .avatar{
            float: left;
            width: 52px;
            height: 52px;
            background-color: #ccc;
            border-radius: 25%;
            margin: 8px;
            background-image: linear-gradient(90deg, #ddd 0px, #e8e8e8 40px, #ddd 80px);
            background-size: 600px;
            animation: shine-avatar 1.6s infinite linear;
            
        }
        .post .line{
            float: left;
            width: 140px;
            height: 16px;
            background-color: #ccc;
            border-radius: 7px;
            margin-top: 12px;
            background-image: linear-gradient(90deg, #ddd 0px, #e8e8e8 40px, #ddd 80px);
            background-size: 600px;
            animation: shine-lines 1.6s infinite linear;
            
        }
        .post .avatar + .line{
            margin-top: 11px;
            width: 100px;
        }

        .post .line ~ .line{
            background-color: #ddd;
        }
        @keyframes shine-lines{
            0%{
                background-position: -100px;
            }
            40%,100%{
                background-position: 140px;
            }
        }
        @keyframes shine-avatar{
            0%{
                background-position: -32px;
            }
            40%,100%{
                background-position: 208px;
            }
        }
    </style>
    <div class="container">
        <div class="post">
            <div class="avatar"></div>
            <div class="line"></div>
            <div class="line"></div>
        </div>
        <div class="post">
            <div class="avatar"></div>
            <div class="line"></div>
            <div class="line"></div>
        </div>
        <div class="post">
            <div class="avatar"></div>
            <div class="line"></div>
            <div class="line"></div>
        </div>
        <div class="post">
            <div class="avatar"></div>
            <div class="line"></div>
            <div class="line"></div>
        </div>
        <div class="post">
            <div class="avatar"></div>
            <div class="line"></div>
            <div class="line"></div>
        </div>
    </div>
</body>
</html>
    
    

Comments