旋转立方体相册

网上看到其他人设计的立方体相册,自己也比着做了一个!


文本结构



second.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <link type="text/css"  href="second.css" rel="stylesheet ">
    <title>旋转立方体相册</title>
</head>
<body>
<div id="react">
    <div class="out_front">
        <img src="../images/a.jpg" class="out_pic">
    </div>
    <div class="out_back">
        <img src="../images/b.jpg" class="out_pic">
    </div>
    <div class="out_left">
        <img src="../images/c.jpg" class="out_pic">
    </div>
    <div class="out_right">
        <img src="../images/d.jpg" class="out_pic">
    </div>
    <div class="out_top">
        <img src="../images/e.jpg" class="out_pic">
    </div>
    <div class="out_bottom">
        <img src="../images/f.jpg" class="out_pic">
    </div>
    <span class="in_front">
        <img src="../images/g.jpg" class="in_pic">
    </span>
    <span class="in_back">
        <img src="../images/h.jpg" class="in_pic">
    </span>
    <span class="in_left">
        <img src="../images/i.jpg" class="in_pic">
    </span>
    <span class="in_right">
        <img src="../images/j.jpg" class="in_pic">
    </span>
    <span class="in_top">
        <img src="../images/k.jpg" class="in_pic">
    </span>
    <span class="in_bottom">
        <img src="../images/l.jpg" class="in_pic">
    </span>
</div>
</body>
</html>


second.css

<pre name="code" class="css">*{
    padding:0;
    margin:0;
}
body{
    width:100%;
    height:100%;
    background:linear-gradient(darkred 0%,black 100%);
}
#react{
    width: 200px;
    height:200px;
    margin: 200px auto;
    transform-style:preserve-3d;
    animation:rotate 20s infinite;
    animation-timing-function: linear;
}
#react div{
    position:absolute;
    transition: all .4s;
}
div .out_pic{
    width:200px;
    height:200px;
    opacity:0.9;
}
div .in_pic{
    width:100px;
    height:100px;
}
#react span{
    display:block;
    position:absolute;
    width:100px;
    height:100px;
    top:50px;
    left:50px;
}
@keyframes rotate{
    from{transform: rotateX(0deg) rotateY(0deg);}
    to{transform: rotateX(360deg) rotateY(360deg);}
}


.out_front{
    transform:translateZ(100px);
}
.out_back{
    transform:translateZ(-100px);
}
.out_left{
    transform:rotateY(90deg) translateZ(100px);
}
.out_right{
    transform: rotateY(-90deg) translateZ(100px);
}
.out_top{
    transform:rotateX(90deg) translateZ(100px);
}
.out_bottom{
    transform: rotateX(-90deg) translateZ(100px);
}
.in_front{
    transform:translateZ(50px);
}
.in_back{
    transform:translateZ(-50px);
}
.in_left{
    transform:rotateY(90deg) translateZ(50px);
}
.in_right{
    transform: rotateY(-90deg) translateZ(50px);
}
.in_top{
    transform:rotateX(90deg) translateZ(50px);
}
.in_bottom{
    transform: rotateX(-90deg) translateZ(50px);
}

/*外面的图片散开*/
#react:hover .out_front{
    transform:translateZ(200px);
}
#react:hover .out_back{
    transform:translateZ(-200px);
}
#react:hover .out_left{
    transform:rotateY(90deg) translateZ(200px);
}
#react:hover .out_right{
    transform: rotateY(-90deg) translateZ(200px);
}
#react:hover .out_top{
    transform:rotateX(90deg) translateZ(200px);
}
#react:hover .out_bottom{
    transform: rotateX(-90deg) translateZ(200px);
}


/*里面的图片散开*/
#react:hover .in_front{
    transform:translateZ(100px);
}
#react:hover .in_back{
    transform:translateZ(-100px);
}
#react:hover .in_left{
    transform:rotateY(90deg) translateZ(100px);
}
#react:hover .in_right{
    transform: rotateY(-90deg) translateZ(100px);
}
#react:hover .in_top{
    transform:rotateX(90deg) translateZ(100px);
}
#react:hover .in_bottom{
    transform: rotateX(-90deg) translateZ(100px);
}

@charset "utf-8";
/* CSS Document */




运行效果

我是在UC浏览器里面运行的




发布了571 篇原创文章 · 获赞 47 · 访问量 51万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览