Sun Aug 28 2022

Animated Image Caption

CSS3569 views

File Name: animated-image-caption.html

<!DOCTYPE html>
<html lang="en">
<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>Animated Image Caption</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300&display=swap" rel="stylesheet"> 
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: 'Nunito', sans-serif;
        }
        
        body {
            background-color: #292929;
        }

        section {
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #usr {
            width: 300px;
            height: 300px;
            background-image: url('https://cdn.pixabay.com/photo/2015/01/15/13/06/woman-600238_960_720.jpg');
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center;
            border-radius: 100%;
            position: relative;
        }

        #usr::before {
            position: absolute;
            content: attr(data-name);
            display: flex;
            justify-content: center;
            align-items: center;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background-color: #5570d9;
            border-radius: 100%;
            font-size: 40px;
            font-weight: 300;
            color: #fff;
            letter-spacing: 3px;
            transform: rotate(360deg) translate(50%, -30%) scale(0.5);
            transition: 0.2s letter-spacing ease-in-out,
                        0.6s transform ease-in-out;
        }

        #usr:hover::before {
            background-color: #5570d9b2;
            letter-spacing: 10px;
            transform: rotate(0deg) translate(0%) scale(1);
            transition: 0.6s transform ease-in-out,
                        2s letter-spacing ease-in-out;
        }

    </style>
</head>
<body>
    <section>
        <div id="usr" data-name="Latika"></div>
    </section>
</body>
</html>

Result Screenshot(s)

Animated Image CaptionWorking Sample0

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.