-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.html
158 lines (126 loc) · 3.64 KB
/
Index.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document</title>
</head>
<style type="text/css">
*{margin:0;padding: 0;}
.pic{
width: 100px;
height: 200px;
/* border: 1px red solid; */
margin: 150px auto 0;
position: relative;
/*transform 旋转元素*/
transform-style:preserve-3d;./
/* 转化为3D效果 */
transform:perspective(800px) rotateX(-10deg) rotateY(0deg) ;
/* 设置视距 */
}
body{background-color: black;overflow:hidden;}
.pic img{
position: absolute;
width: 100%;
height: 100%;
/* border-radius: 5px; */
box-shadow: 0px 0px 10px #fff;
/*倒影的设置*/
-webkit-box-reflect:below 10px -webkit-linear-gradient(top,rgba(0,0,0,0) 50%,rgba(0,0,0,.5) 100%);
/* 因为box-reflect非W3C标准语法,仅在Chrome、Safari和Opera浏览器下支持加前缀-webkit
-webkit-box-reflect:none direction offset mask-box-image;
none表示无倒影效果---不要写.
direction可取值:
above:表示生成的倒影在对象(原图)的上方;
below:表示生成的倒影在对象(原图)的下方;
left:表示生成的倒影在对象(原图)的左侧;
right:表示生成的倒影在对象(原图)的右侧;
offset表示两者之间的距离 可取值像素和百分比.
mask-box-image 遮罩层可以写渐变效果 和 图片url */
}
.pic p{
width: 1200px;
height: 1200px;
background: -webkit-radial-gradient(center center,600px 600px,rgba(255,255,255,.5),rgba(0,0,0,0));
position: absolute;
/* 相对于父级绝对定位 */
top:100%;left:50%;
margin-top: -600px;
margin-left: -600px;
border-radius:600px;
transform:rotateX(90deg);
}
/* 下边托盘 */
</style>
<body>
<div class="pic">
<img src="images/1.png"/>
<img src="images/2.gif"/>
<img src="images/3.gif"/>
<img src="images/4.gif"/>
<img src="images/5.gif"/>
<img src="images/6.gif"/>
<img src="images/2.jpg"/>
<img src="images/1.jpg"/>
<p></p>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(function(){
var imgL=$(".pic img").size();
// size匹配元素的数量,imgL 图片总数
var deg=360/imgL;
// 根据图片数量等分角度
var roY=0,roX=-10;
var xN=0,yN=0;
var play=null;
$(".pic img").each(function(index){
$(this).css({
// <!---translateZ 定义2d旋转沿着z轴->
"transform":"rotateY("+index*deg+"deg) translateZ(300px)" });
// <!--防止图片被拖拽-->
$(this).attr('ondragstart','return false');
});
$(document).mousedown(function(ev){
var x_=ev.clientX;
var y_=ev.clientY;
// clientX返回被触发是鼠标按下的坐标
clearInterval(play);
console.log('我按下了');
$(this).bind('mousemove',function(ev){
/*获取当前鼠标的坐标*/
var x=ev.clientX;
var y=ev.clientY;
/*两次坐标之间的距离*/
xN=x-x_;
yN=y-y_;
roY+=xN*0.2;
roX-=yN*0.1;
console.log('移动');
//$('body').append('<div style="width:5px;height:5px;position:absolute;top:'+y+'px;left:'+x+'px;background-color:red"></div>');
$('.pic').css({
transform:'perspective(800px) rotateX('+roX+'deg) rotateY('+roY+'deg)'
});
/*之前的鼠标坐标*/
x_=ev.clientX;
y_=ev.clientY;
});
}).mouseup(function(){
$(this).unbind('mousemove');
var play=setInterval(function(){
xN*=0.95;
yN*=0.95
if(Math.abs(xN)<1 && Math.abs(yN)<1){
clearInterval(play);
}
roY+=xN*0.2;
roX-=yN*0.1;
$('.pic').css({
transform:'perspective(800px) rotateX('+roX+'deg) rotateY('+roY+'deg)'
});
},30);
});
});
</script>
</body>
</html>