CSS 3D六面盒子制作


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Documenttitle>
    <style>
        html{
      
            perspective:800px;
        }
        .cube{
      
            width: 200px;
            height: 200px;
            background-color:#bfa;
            margin:100px auto;
            /* 设置3D变形效果 */
            transform-style: preserve-3d;
            /* transform:rotateX(45deg) rotateZ(45deg); */
            animation: rotate 20s infinite linear;
        }
        .cube > div{
      
            width: 200px;
            height: 200px;
            /* 为元素设置透明效果 */
            opacity: 0.7;
            position: absolute;
        }
        img{
      
            vertical-align:top;
        }
        .box1{
      
            transform: rotateY(90deg) translateZ(100px);
        }
        .box2{
      
            transform: rotateY(-90deg) translateZ(100px);
        }
        .box3{
      
            transform: rotateX(90deg) translateZ(100px);
        }
        .box4{
      
            transform: rotateX(-90deg) translateZ(100px);
        }
        .box5{
      
            transform: rotateY(180deg) translateZ(100px);
        }
        .box6{
      
            transform: rotateY(0) translateZ(100px);
        }
        @keyframes rotate {
      
            from{
      
                transform:rotateX(0) rotateZ(0);
            }
            to{
      
                transform:rotateX(1turn) rotateZ(1turn);
            }
        }
    style>
head>
<body>
    <div class="cube">
        
        <div class="box1">
            <img src="1.jpg" alt="">
            
        div>
        <div class="box2">
            <img src="2.jpg" alt="">
        div>
        <div class="box3">
            <img src="3.jpg" alt="">
        div>
        <div class="box4">
            <img src="4.jpg" alt="">
        div>
        <div class="box5">
            <img src="5.jpg" alt="">
        div>
        <div class="box6">
            <img src="6.jpg" alt="">
        div>
    div>
body>
html>

你可能感兴趣的:(前端,css)