Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
2.2 kB
0
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D Rotating Cube</title>
    <style>
        body, html {
            height: 100%;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #282c34;
            color: white;
            font-family: Arial, sans-serif;
        }
        .scene {
            width: 200px;
            height: 200px;
            perspective: 600px;
        }
        .cube {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            transform: rotateX(-30deg) rotateY(-45deg);
            animation: rotate 10s infinite linear;
        }
        .cube__face {
            position: absolute;
            width: 200px;
            height: 200px;
            background: rgba(255, 255, 255, 0.8);
            border: 1px solid #ccc;
        }
        .cube__face--front  { transform: translateZ(100px); }
        .cube__face--back   { transform: rotateY(180deg) translateZ(100px); }
        .cube__face--right  { transform: rotateY(90deg) translateZ(100px); }
        .cube__face--left   { transform: rotateY(-90deg) translateZ(100px); }
        .cube__face--top    { transform: rotateX(90deg) translateZ(100px); }
        .cube__face--bottom { transform: rotateX(-90deg) translateZ(100px); }

        @keyframes rotate {
            from {
                transform: rotateX(-30deg) rotateY(-45deg);
            }
            to {
                transform: rotateX(-30deg) rotateY(315deg);
            }
        }
    </style>
</head>
<body>
    <div class="scene">
        <div class="cube">
            <div class="cube__face cube__face--front">Front</div>
            <div class="cube__face cube__face--back">Back</div>
            <div class="cube__face cube__face--right">Right</div>
            <div class="cube__face cube__face--left">Left</div>
            <div class="cube__face cube__face--top">Top</div>
            <div class="cube__face cube__face--bottom">Bottom</div>
        </div>
    </div>
</body>
</html>
Leave a Comment