-
Notifications
You must be signed in to change notification settings - Fork 0
/
3dPhoto.html
75 lines (74 loc) · 1.82 KB
/
3dPhoto.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>端午节快乐</title>
</head>
<style type="text/css">
* {
padding: 0px;
margin: 0px
}/*消除 dom 元素的内外边距,使我们写 css 的时候更精准*/
body {
background: #000
}
#photos{
width: 110px;
height: 180px;
border: 1px solid #ccc;
margin: 160px auto;
transform: rotateY(0deg);
transform-style: preserve-3d;
transform:rotateX(-10deg);
perspective: 800px;/*景深*/
}
#photos img{
width: 100%;
height: 100%;
position: absolute;
box-shadow: 0 0 8px #eaeaea;
box-shadow: 1px -1px 6px #666;
border-radius: 4px;
-webkit-box-reflect:below 3px -webkit-linear-gradient(top,rgba(0,0,0,0) 40%,rgba(0,0,0,0.5));
cursor: pointer;
}
#photos div{
width: 1200px;
height: 1200px;
border-radius: 50%;
position: absolute;
top: 102%;
left: 50%;
margin-left: -600px;
margin-top: -600px;
transform: rotateX(90deg);
background: -webkit-radial-gradient(center center,600px 600px,rgba(158,158,222,0.5),rgba(0,0,0,0));
}
</style>
<body>
<div id = 'photos'>
<img src='./images/p1.jpg'></img>
<img src='./images/p2.jpg'></img>
<img src='./images/p3.jpg'></img>
<img src='./images/p4.jpg'></img>
<img src='./images/p5.jpg'></img>
<img src='./images/p6.jpg'></img>
<img src='./images/p7.jpg'></img>
<img src='./images/p8.jpg'></img>
<div></div>
</div>
</body>
<script type="text/javascript">
var photosDOM = document.getElementById("photos");
var images = document.getElementsByTagName("img");
var imgSum = images.length;
var deg = Math.floor(360/imgSum);
for (let i = 0; i < imgSum; i++) {
images[i].style = 'transform: rotateY('+deg*i+'deg) translateZ(380px)';
}
var x = 0;
setInterval(function() {
photosDOM.style.transform = 'rotateX(-10deg) rotateY('+ (x++) * 0.2 +'deg)'
}, 30);
</script>>
</html>