Fri Apr 22 2022

3D Image Effect on Hover

CSS5082 views

File Name: 3D-image-effect-in-css3.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>3D image effect on hover</title>
    <style>
        body {
            background-color: #383838;
        }        

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

        .container {
            width: 300px;
            height: 450px;
            position: relative;
            transform: rotate(-30deg) skew(25deg) scale(0.8);
            box-shadow: 0 0 50px 0 #181818;
        }

        .container img {
            position: absolute;
            width: 100%;
            transition: 0.4s all linear;
        }

        .container:hover img:nth-child(5) {
            transform: translate(160px, -160px);
            opacity: 1;
        }
        
        .container:hover img:nth-child(4) {
            transform: translate(120px, -120px);
            opacity: 0.8;
        }

        .container:hover img:nth-child(3) {
            transform: translate(80px, -80px);
            opacity: 0.6;
        }

        .container:hover img:nth-child(2) {
            transform: translate(40px, -40px);
            opacity: 0.4;
        }

        .container:hover img:nth-child(1) {
            opacity: 0.2;
        }
        
    </style>
</head>
<body>
    <section>
        <div class="container">
            <img src="https://cdn.pixabay.com/photo/2019/08/02/23/09/man-4380804_960_720.jpg" alt="">
            <img src="https://cdn.pixabay.com/photo/2019/08/02/23/09/man-4380804_960_720.jpg" alt="">
            <img src="https://cdn.pixabay.com/photo/2019/08/02/23/09/man-4380804_960_720.jpg" alt="">
            <img src="https://cdn.pixabay.com/photo/2019/08/02/23/09/man-4380804_960_720.jpg" alt="">
            <img src="https://cdn.pixabay.com/photo/2019/08/02/23/09/man-4380804_960_720.jpg" alt="">
        </div>
    </section>
</body>
</html>

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