ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

3D旋转相册

2021-04-05 17:35:23  阅读:198  来源: 互联网

标签:cube 相册 translateZ transform 旋转 rotateY 400px out 3D


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>12生肖相册</title>
<style>
html{
    background: #000;
    height: 100%;    
}
/*最外层容器样式*/
.wrap{ 
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 400px;
    height: 400px;
    margin: auto;
    /*改变左右上下,图片方块移动*/
    
}
/*包裹所有容器样式*/
.cube{
    width: 400px;
    height: 400px;
    margin: 0 auto;
    /*所有子元素在3D空间中呈现*/
    transform-style: preserve-3d;
    /*Transform属性应用于元素的2D或3D转换。*/
    /*沿着X轴旋转 -30度, 沿着Y轴旋转 -80度*/
    transform: rotateX(-30deg) rotateY(-80deg);
    /*把 animation 绑定到rotate*/
    -webkit-animation: rotate 20s infinite;
    /*匀速*/
    animation-timing-function: linear;
}
/*创建动画是通过逐步改变从一个CSS样式设定到另一个。*/
@-webkit-keyframes rotate{
    from{transform: rotateX(0deg) rotateY(0deg);}
    to{transform: rotateX(360deg) rotateY(360deg);}
}
.cube div{
    position: absolute;
    width: 400px;
    height: 400px;
    opacity: 0.8;  /*指定不透明度。从0.0(完全透明)到1.0(完全不透明)*/
    transition: all 5s;  /*所有属性 过度效果 持续5s*/
}
/*定义所有图片样式*/
.pic{
    width: 400px;
    height: 400px;
}
.cube .out_front{
    transform: rotateY(0deg) translateZ(200px);
}
.cube .out_back{
    transform: translateZ(-200px) rotateY(180deg);
}
.cube .out_left{
    transform: rotateY(90deg) translateZ(200px);
}
.cube .out_right{
    transform: rotateY(-90deg) translateZ(200px);
}
.cube .out_top{
    transform: rotateX(90deg) translateZ(200px);
}
.cube .out_bottom{
    transform: rotateX(-90deg) translateZ(200px);
}
/*定义小正方体样式*/
.cube span{
    display: bloack;
    width: 200px;
    height: 200px;
    position: absolute;
    top: 100px;
    left: 100px;
}
.cube .in_pic{
    width: 200px;
    height: 200px;
}
.cube .in_front{
    transform: rotateY(0deg) translateZ(100px);
}
.cube .in_back{
    transform: translateZ(-100px) rotateY(180deg);
}
.cube .in_left{
    transform: rotateY(90deg) translateZ(100px);
}
.cube .in_right{
    transform: rotateY(-90deg) translateZ(100px);
}
.cube .in_top{
    transform: rotateX(90deg) translateZ(100px);
}
.cube .in_bottom{
    transform: rotateX(-90deg) translateZ(100px);
}
/*鼠标移入后样式*/
.cube:hover .out_front{
    transform: rotateY(0deg) translateZ(400px);
}
.cube:hover .out_back{
    transform: translateZ(-400px) rotateY(180deg);
}
.cube:hover .out_left{
    transform: rotateY(90deg) translateZ(400px);
}
.cube:hover .out_right{
    transform: rotateY(-90deg) translateZ(400px);
}
.cube:hover .out_top{
    transform: rotateX(90deg) translateZ(400px);
}
.cube:hover .out_bottom{
    transform: rotateX(-90deg) translateZ(400px);
html{
    background: #000;
    height: 100%;    
}
/*最外层容器样式*/
.wrap{ 
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 400px;
    height: 400px;
    margin: auto;
    /*改变左右上下,图片方块移动*/
    
}
/*包裹所有容器样式*/
.cube{
    width: 400px;
    height: 400px;
    margin: 0 auto;
    /*所有子元素在3D空间中呈现*/
    transform-style: preserve-3d;
    /*Transform属性应用于元素的2D或3D转换。*/
    /*沿着X轴旋转 -30度, 沿着Y轴旋转 -80度*/
    transform: rotateX(-30deg) rotateY(-80deg);
    /*把 animation 绑定到rotate*/
    -webkit-animation: rotate 20s infinite;
    /*匀速*/
    animation-timing-function: linear;
}
/*创建动画是通过逐步改变从一个CSS样式设定到另一个。*/
@-webkit-keyframes rotate{
    from{transform: rotateX(0deg) rotateY(0deg);}
    to{transform: rotateX(360deg) rotateY(360deg);}
}
.cube div{
    position: absolute;
    width: 400px;
    height: 400px;
    opacity: 0.8;  /*指定不透明度。从0.0(完全透明)到1.0(完全不透明)*/
    transition: all 5s;  /*所有属性 过度效果 持续5s*/
}
/*定义所有图片样式*/
.pic{
    width: 400px;
    height: 400px;
}
.cube .out_front{
    transform: rotateY(0deg) translateZ(200px);
}
.cube .out_back{
    transform: translateZ(-200px) rotateY(180deg);
}
.cube .out_left{
    transform: rotateY(90deg) translateZ(200px);
}
.cube .out_right{
    transform: rotateY(-90deg) translateZ(200px);
}
.cube .out_top{
    transform: rotateX(90deg) translateZ(200px);
}
.cube .out_bottom{
    transform: rotateX(-90deg) translateZ(200px);
}
/*定义小正方体样式*/
.cube span{
    display: bloack;
    width: 200px;
    height: 200px;
    position: absolute;
    top: 100px;
    left: 100px;
}
.cube .in_pic{
    width: 200px;
    height: 200px;
}
.cube .in_front{
    transform: rotateY(0deg) translateZ(100px);
}
.cube .in_back{
    transform: translateZ(-100px) rotateY(180deg);
}
.cube .in_left{
    transform: rotateY(90deg) translateZ(100px);
}
.cube .in_right{
    transform: rotateY(-90deg) translateZ(100px);
}
.cube .in_top{
    transform: rotateX(90deg) translateZ(100px);
}
.cube .in_bottom{
    transform: rotateX(-90deg) translateZ(100px);
}
/*鼠标移入后样式*/
.cube:hover .out_front{
    transform: rotateY(0deg) translateZ(400px);
}
.cube:hover .out_back{
    transform: translateZ(-400px) rotateY(180deg);
}
.cube:hover .out_left{
    transform: rotateY(90deg) translateZ(400px);
}
.cube:hover .out_right{
    transform: rotateY(-90deg) translateZ(400px);
}
.cube:hover .out_top{
    transform: rotateX(90deg) translateZ(400px);
}
.cube:hover .out_bottom{
    transform: rotateX(-90deg) translateZ(400px);
html{
    background: #000;
    height: 100%;    
}
/*最外层容器样式*/
.wrap{ 
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 400px;
    height: 400px;
    margin: auto;
    /*改变左右上下,图片方块移动*/
    
}
/*包裹所有容器样式*/
.cube{
    width: 400px;
    height: 400px;
    margin: 0 auto;
    /*所有子元素在3D空间中呈现*/
    transform-style: preserve-3d;
    /*Transform属性应用于元素的2D或3D转换。*/
    /*沿着X轴旋转 -30度, 沿着Y轴旋转 -80度*/
    transform: rotateX(-30deg) rotateY(-80deg);
    /*把 animation 绑定到rotate*/
    -webkit-animation: rotate 20s infinite;
    /*匀速*/
    animation-timing-function: linear;
}
/*创建动画是通过逐步改变从一个CSS样式设定到另一个。*/
@-webkit-keyframes rotate{
    from{transform: rotateX(0deg) rotateY(0deg);}
    to{transform: rotateX(360deg) rotateY(360deg);}
}
.cube div{
    position: absolute;
    width: 400px;
    height: 400px;
    opacity: 0.8;  /*指定不透明度。从0.0(完全透明)到1.0(完全不透明)*/
    transition: all 5s;  /*所有属性 过度效果 持续5s*/
}
/*定义所有图片样式*/
.pic{
    width: 400px;
    height: 400px;
}
.cube .out_front{
    transform: rotateY(0deg) translateZ(200px);
}
.cube .out_back{
    transform: translateZ(-200px) rotateY(180deg);
}
.cube .out_left{
    transform: rotateY(90deg) translateZ(200px);
}
.cube .out_right{
    transform: rotateY(-90deg) translateZ(200px);
}
.cube .out_top{
    transform: rotateX(90deg) translateZ(200px);
}
.cube .out_bottom{
    transform: rotateX(-90deg) translateZ(200px);
}
/*定义小正方体样式*/
.cube span{
    display: bloack;
    width: 200px;
    height: 200px;
    position: absolute;
    top: 100px;
    left: 100px;
}
.cube .in_pic{
    width: 200px;
    height: 200px;
}
.cube .in_front{
    transform: rotateY(0deg) translateZ(100px);
}
.cube .in_back{
    transform: translateZ(-100px) rotateY(180deg);
}
.cube .in_left{
    transform: rotateY(90deg) translateZ(100px);
}
.cube .in_right{
    transform: rotateY(-90deg) translateZ(100px);
}
.cube .in_top{
    transform: rotateX(90deg) translateZ(100px);
}
.cube .in_bottom{
    transform: rotateX(-90deg) translateZ(100px);
}
/*鼠标移入后样式*/
.cube:hover .out_front{
    transform: rotateY(0deg) translateZ(400px);
}
.cube:hover .out_back{
    transform: translateZ(-400px) rotateY(180deg);
}
.cube:hover .out_left{
    transform: rotateY(90deg) translateZ(400px);
}
.cube:hover .out_right{
    transform: rotateY(-90deg) translateZ(400px);
}
.cube:hover .out_top{
    transform: rotateX(90deg) translateZ(400px);
}
.cube:hover .out_bottom{
    transform: rotateX(-90deg) translateZ(400px);
}
</style>
</head>
<body>
    <audio autoplay="autopaly">
        <source src="http://www.170mv.com/kw/antiserver.kuwo.cn/anti.s?rid=MUSIC_450897&response=res&format=mp3|aac&type=convert_url&br=128kmp3&agent=iPhone&callback=getlink&jpcallback=getlink.mp3" type="audio/mp3" />
    </audio>    
    <div class="wrap">
        <div class="cube">
            <div class="out_front"><img class="pic" src="https://img1.baidu.com/it/u=2075923439,130195505&fm=26&fmt=auto&gp=0.jpg" /></div>
            <div class="out_back"><img class="pic" src="https://img0.baidu.com/it/u=1618045890,1946795229&fm=26&fmt=auto&gp=0.jpg" /></div>
            <div class="out_left"><img class="pic" src="https://img1.baidu.com/it/u=1223391585,3286738355&fm=26&fmt=auto&gp=0.jpg" /></div>
            <div class="out_right"><img class="pic" src="https://img1.baidu.com/it/u=2200028431,483217992&fm=26&fmt=auto&gp=0.jpg" /></div>
            <div class="out_top"><img class="pic" src="https://img2.baidu.com/it/u=2993781392,3407187010&fm=26&fmt=auto&gp=0.jpg" /></div>
            <div class="out_bottom"><img class="pic" src="https://img0.baidu.com/it/u=2221924116,4011503413&fm=26&fmt=auto&gp=0.jpg" /></div>
            <span class="in_front"><img class="in_pic" src="https://img1.baidu.com/it/u=2200405074,417952639&fm=26&fmt=auto&gp=0.jpg" /></span>
            <span class="in_back"><img class="in_pic" src="https://img2.baidu.com/it/u=2608585042,3503219609&fm=26&fmt=auto&gp=0.jpg" /></span>
            <span class="in_left"><img class="in_pic" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.17qq.com%2Fimg_biaoqing%2F29716497.jpeg&refer=http%3A%2F%2Fwww.17qq.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1620206293&t=81ab4cb402e99c0a29569d208c3f5574" /></span>
            <span class="in_right"><img class="in_pic" src="https://img2.baidu.com/it/u=3046194809,1441608319&fm=26&fmt=auto&gp=0.jpg" /></span>
            <span class="in_top"><img class="in_pic" src="https://img2.baidu.com/it/u=3441181052,2560166791&fm=26&fmt=auto&gp=0.jpg" /></span>
            <span class="in_bottom"><img class="in_pic" src="https://img0.baidu.com/it/u=2356217897,2053847174&fm=26&fmt=auto&gp=0.jpg" /></span>
        </div>
    </div>
</body>
</html>

 

标签:cube,相册,translateZ,transform,旋转,rotateY,400px,out,3D
来源: https://www.cnblogs.com/HelloM/p/14618847.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有