源码链接:https://gitee.com/cungudafa/css-3d
下载解压,只需替换css-3d项目中img下的照片就可以了,注意不要修改照片的名字
双击index.html就可以显示 3d相册 的网页效果啦!
源码:
/*背景页面颜色设置*/
html{
background:linear-gradient(#FF6666 0%,#336699 20%);/*背景颜色渐变*/
height: 100%;
color:#99cc33;/*字体颜色*/
}
/*动态样式设置*/
/*最外层容器样式*/
.wrap{
width: 200px;
height: 200px;
/*改变左右上下,图片方块移动*/
margin: 150px auto;
position: relative;
}
/*包裹所有容器样式*/
.cube{
width: 200px;
height: 200px;
margin: 0 auto;
transform-style: preserve-3d;
transform: rotateX(-30deg) rotateY(-80deg);
-webkit-animation: rotate 20s infinite;
/*匀速*/
animation-timing-function: linear;
}
@-webkit-keyframes rotate{
from{transform: rotateX(0deg) rotateY(0deg);}
to{transform: rotateX(360deg) rotateY(360deg);}
}
.cube div{
position: absolute;
width: 200px;
height: 200px;
opacity: 0.8;
transition: all .4s;
}
/*定义所有图片样式*/
.pic{
width: 200px;
height: 200px;
}
.cube .out_front{
transform: rotateY(0deg) translateZ(100px);
}
.cube .out_back{
transform: translateZ(-100px) rotateY(180deg);
}
.cube .out_left{
transform: rotateY(90deg) translateZ(100px);
}
.cube .out_right{
transform: rotateY(-90deg) translateZ(100px);
}
.cube .out_top{
transform: rotateX(90deg) translateZ(100px);
}
.cube .out_bottom{
transform: rotateX(-90deg) translateZ(100px);
}
/*定义小正方体样式
*/
.cube span{
display: bloack;
width: 100px;
height: 100px;
position: absolute;
top: 50px;
left: 50px;
}
.cube .in_pic{
width: 100px;
height: 100px;
}
.cube .in_front{
transform: rotateY(0deg) translateZ(50px);
}
.cube .in_back{
transform: translateZ(-50px) rotateY(180deg);
}
.cube .in_left{
transform: rotateY(90deg) translateZ(50px);
}
.cube .in_right{
transform: rotateY(-90deg) translateZ(50px);
}
.cube .in_top{
transform: rotateX(90deg) translateZ(50px);
}
.cube .in_bottom{
transform: rotateX(-90deg) translateZ(50px);
}
/*鼠标移入后样式*/
.cube:hover .out_front{
transform: rotateY(0deg) translateZ(200px);
}
.cube:hover .out_back{
transform: translateZ(-200px) rotateY(180deg);
}
.cube:hover .out_left{
transform: rotateY(90deg) translateZ(200px);
}
.cube:hover .out_right{
transform: rotateY(-90deg) translateZ(200px);
}
.cube:hover .out_top{
transform: rotateX(90deg) translateZ(200px);
}
.cube:hover .out_bottom{
transform: rotateX(-90deg) translateZ(200px);
}
.hovertreeinfo{text-align:center;}
.hovertreeinfo a{color:white}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>css-3d旋转相册</title>
<link rel="stylesheet" href="css/hovertree.css" />
</head>
<body>
<div class="hovertreeinfo">
<h2></h2>红豆
</div>
<!--/*外层最大容器*/-->
<div class="wrap">
<!-- /*包裹所有元素的容器*/-->
<div class="cube">
<!--前面图片 -->
<div class="out_front">
<img src="img/img01.jpg " class="pic" />
</div>
<!--后面图片 -->
<div class="out_back">
<img src="img/img02.jpg" class="pic"/>
</div>
<!--左图片 -->
<div class="out_left">
<img src="img/img03.jpg" class="pic" />
</div>
<div class="out_right">
<img src="img/img04.jpg" class="pic" />
</div>
<div class="out_top">
<img src="img/img05.jpg" class="pic" />
</div>
<div class="out_bottom">
<img src="img/img06.jpg" class="pic" />
</div>
<!--小正方体 -->
<span class="in_front">
<img src="img/img07.jpg" class="in_pic" />
</span>
<span class="in_back">
<img src="img/img08.jpg" class="in_pic" />
</span>
<span class="in_left">
<img src="img/img09.jpg" class="in_pic" />
</span>
<span class="in_right">
<img src="img/img10.jpg" class="in_pic" />
</span>
<span class="in_top">
<img src="img/img11.jpg" class="in_pic" />
</span>
<span class="in_bottom">
<img src="img/img12.jpg" class="in_pic" />
</span>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>css-3d旋转相册</title>
<link rel="stylesheet" href="css/hovertree.css" />
</head>
<body>
<div class="hovertreeinfo">
<h2>css-3d旋转相册</h2>请把光标移到立方体上面,或者点击图片。
</div>
<!--/*外层最大容器*/-->
<div class="wrap">
<!-- /*包裹所有元素的容器*/-->
<div class="cube">
<!--前面图片 -->
<div class="out_front">
<img src="http://www.jd-tv.com/uploads/allimg/180822/18-1PR2110G0N0.jpg" class="pic" />
</div>
<!--后面图片 -->
<div class="out_back">
<img src="https://img.yna.co.kr/etc/inner/CK/2018/07/26/ACK20180726001500881_01_i_P4.jpg" class="pic" />
</div>
<!--左图片 -->
<div class="out_left">
<img src="http://www.weimeicun.com/uploads/allimg/181109/1010-1Q109152421Q8.jpg" class="pic" />
</div>
<div class="out_right">
<img src="http://p3.ifengimg.com/cmpp/2016/07/20/13/cdf377cd-ca7f-41f3-b481-c99561a0a40e_size29_w500_h332.jpg" class="pic" />
</div>
<div class="out_top">
<img src="http://img.mm4000.com/file/9/49/c43d6065b5_1044.jpg" class="pic" />
</div>
<div class="out_bottom">
<img src="http://imgs.jushuo.com/dimg/2016-12-16/58535d65478d9.jpg" class="pic" />
</div>
<!--小正方体 -->
<span class="in_front">
<img src="http://p0.ifengimg.com/pmop/2018/0404/B05F7F3EEDA9A308722D757446A5357677F77C79_size64_w540_h700.jpeg" class="in_pic" />
</span>
<span class="in_back">
<img src="http://p3.ifengimg.com/a/2018_30/e7dfb1ff77a73ff_size29_w499_h624.jpg" class="in_pic" />
</span>
<span class="in_left">
<img src="http://img1.xiazaizhijia.com/walls/20160801/middle_510aafcd093f6a2.jpg" class="in_pic" />
</span>
<span class="in_right">
<img src="https://cn.bing.com/th?id=OIP.LpZnh1XtRA4buMi5P4qOegHaKh&pid=Api&rs=1" class="in_pic" />
</span>
<span class="in_top">
<img src="http://www.sosoxian.com/uploads/allimg/160926/1-160926091526.jpg" class="in_pic" />
</span>
<span class="in_bottom">
<img src="https://n.sinaimg.cn/ent/transform/20160720/Cdjh-fxuapvw2412326.jpg" class="in_pic" />
</span>
</div>
</div>
</body>
</html>
第二步:html加音频自动播放
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>css-3d旋转相册</title>
<link rel="stylesheet" href="css/hovertree.css" />
</head>
<body>
<div class="hovertreeinfo">
<h2></h2>红豆
</div>
<!-- 仅自动播放音乐 -->
<audio loop src="img/qianyuqianxun.mp3" id="audio" autoplay preload="auto">该浏览器不支持audio属性</audio>
<!-- 显示播放条 controls -->
<!-- <audio loop src="img/qianyuqianxun.mp3" id="audio" controls autoplay preload="auto">该浏览器不支持audio属性</audio> -->
<script type="text/javascript">
//--创建页面监听,等待微信端页面加载完毕 触发音频播放
document.addEventListener('DOMContentLoaded', function () {
function audioAutoPlay() {
var audio = document.getElementById('audio');
audio.play();
document.addEventListener("WeixinJSBridgeReady", function () {
audio.play();
}, false);
}
audioAutoPlay();
});
//--创建触摸监听,当浏览器打开页面时,触摸屏幕触发事件,进行音频播放
document.addEventListener('touchstart', function () {
function audioAutoPlay() {
var audio = document.getElementById('audio');
audio.play();
}
audioAutoPlay();
});
</script>
<!--/*外层最大容器*/-->
<div class="wrap">
<!-- /*包裹所有元素的容器*/-->
<div class="cube">
<!--前面图片 -->
<div class="out_front">
<img src="img/img06.jpg " class="pic" />
</div>
<!--后面图片 -->
<div class="out_back">
<img src="img/img07.jpg" class="pic"/>
</div>
<!--左图片 -->
<div class="out_left">
<img src="img/img08.jpg" class="pic" />
</div>
<div class="out_right">
<img src="img/img04.jpg" class="pic" />
</div>
<div class="out_top">
<img src="img/img10.jpg" class="pic" />
</div>
<div class="out_bottom">
<img src="img/img11.jpg" class="pic" />
</div>
<!--小正方体 -->
<span class="in_front">
<img src="img/img01.jpg" class="in_pic" />
</span>
<span class="in_back">
<img src="img/img02.jpg" class="in_pic" />
</span>
<span class="in_left">
<img src="img/img03.jpg" class="in_pic" />
</span>
<span class="in_right">
<img src="img/img09.jpg" class="in_pic" />
</span>
<span class="in_top">
<img src="img/img05.jpg" class="in_pic" />
</span>
<span class="in_bottom">
<img src="img/img12.jpg" class="in_pic" />
</span>
</div>
</div>
</body>
</html>
旋转图像,播放音乐
用win+G录制音视频