Adding a flippable image inside a container?

Viewed 27

I've been working on a site for a friend and I'm attempting to have the inserted image flip over (code below). It won't scale with the container it's in if I apply a card flip animation to it, but it scales perfectly as a plain old image. Is it possible to include the animation so it sits neatly within the box under the border?

<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        .flip-card {
            background-color: transparent;
            width: 300px;
            height: 300px;
            perspective: 1000px;
        }

        .flip-card-inner {
            position: absolute;
            width: 118.7%;
            height: 100%;
            text-align: center;
            transition: transform 0.6s;
            transform-style: preserve-3d;
        }

        .flip-card:hover .flip-card-inner {
            transform: rotateY(180deg);
        }

        .flip-card-front,
        .flip-card-back {
            position: absolute;
            width: 100%;
            height: 100%;
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
        }

        .flip-card-front {
            background-color: #000000;
            color: black;
        }

        .flip-card-back {
            background-color: #000000;
            color: white;
            transform: rotateY(180deg);
        }
    </style>
</head>

<body>
    <div class="container">
        <hr class="solid">
        <div class="flip-card">
            <div class="flip-card-inner">
                <div class="flip-card-front">
                    <img src="image.png" style="width:300px;height:300px;">
                </div>
                <div class="flip-card-back">
                </div>
            </div>
        </div>
    </div>
</body>

</html>

0 Answers
Related