質問編集履歴
2
コード編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -304,10 +304,6 @@
|
|
304
304
|
|
305
305
|
$('.cube').css({'transform':'translateZ(-'+wW/2+'px) rotateY('+moveDeg+'deg)'});
|
306
306
|
|
307
|
-
$('.cube').css({'transform':'rotateY(0deg)'});
|
308
|
-
|
309
|
-
$("#cube1").attr('');
|
310
|
-
|
311
307
|
},1000);
|
312
308
|
|
313
309
|
},500);
|
1
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,331 @@
|
|
1
1
|
キューブ型にしたサイトを回転させてコンテンツを変えているんですが、90度回転ですと右回転、その後さらに90度回転させて180度回転させるときに左回転になってしまいます。
|
2
2
|
|
3
3
|
回転する向きを統一する方法はありますか?
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
```HTML
|
8
|
+
|
9
|
+
<div class="stage">
|
10
|
+
|
11
|
+
<div class="cube">
|
12
|
+
|
13
|
+
<!-- 横回転 -->
|
14
|
+
|
15
|
+
<div id="cube1" class="cube_front active">
|
16
|
+
|
17
|
+
FRONT
|
18
|
+
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div id="cube2" class="cube_back">
|
22
|
+
|
23
|
+
BACK
|
24
|
+
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div id="cube3" class="cube_right">
|
28
|
+
|
29
|
+
RIGHT
|
30
|
+
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div id="cube4" class="cube_left">
|
34
|
+
|
35
|
+
LEFT
|
36
|
+
|
37
|
+
</div>
|
38
|
+
|
39
|
+
</div>
|
40
|
+
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div class="nav">
|
44
|
+
|
45
|
+
<ul>
|
46
|
+
|
47
|
+
<!-- <li><a data-deg="0" class="active" href="#">0deg</a></li> -->
|
48
|
+
|
49
|
+
<li><a data-deg="90" href="#">90deg</a></li>
|
50
|
+
|
51
|
+
<li><a data-deg="-90" href="#">-90deg</a></li>
|
52
|
+
|
53
|
+
</ul>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
```css
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
/* id */
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
/* class */
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
.stage {
|
74
|
+
|
75
|
+
position: fixed;
|
76
|
+
|
77
|
+
top: 0;
|
78
|
+
|
79
|
+
left: 0;
|
80
|
+
|
81
|
+
-webkit-perspective: 1000;
|
82
|
+
|
83
|
+
-ms-perspective: 1000;
|
84
|
+
|
85
|
+
-o-perspective: 1000;
|
86
|
+
|
87
|
+
-moz-perspective: 1000px;
|
88
|
+
|
89
|
+
perspective: 1000;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
.cube {
|
96
|
+
|
97
|
+
position: relative;
|
98
|
+
|
99
|
+
margin:0 auto;
|
100
|
+
|
101
|
+
transform-style: preserve-3d;
|
102
|
+
|
103
|
+
transition:all 1s;
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
.cube div {
|
110
|
+
|
111
|
+
position: absolute;
|
112
|
+
|
113
|
+
color: #fff;
|
114
|
+
|
115
|
+
text-align: center;
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
/* 横回転 */
|
122
|
+
|
123
|
+
.cube_front {
|
124
|
+
|
125
|
+
top: 0px;
|
126
|
+
|
127
|
+
left: 0px;
|
128
|
+
|
129
|
+
background-image:url(/test/test4.jpg);
|
130
|
+
|
131
|
+
background-repeat:no-repeat;
|
132
|
+
|
133
|
+
background-position:center center;
|
134
|
+
|
135
|
+
background-size:cover;
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
.cube_back {
|
142
|
+
|
143
|
+
top: 0px;
|
144
|
+
|
145
|
+
left: 0px;
|
146
|
+
|
147
|
+
background-image:url(/test/test3.jpeg);
|
148
|
+
|
149
|
+
background-repeat:no-repeat;
|
150
|
+
|
151
|
+
background-position:center center;
|
152
|
+
|
153
|
+
background-size:cover;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
.cube_right {
|
160
|
+
|
161
|
+
top: 0px;
|
162
|
+
|
163
|
+
-webkit-transform: rotateY(90deg);
|
164
|
+
|
165
|
+
transform: rotateY(90deg);
|
166
|
+
|
167
|
+
background-image:url(/test/test2.jpg);
|
168
|
+
|
169
|
+
background-repeat:no-repeat;
|
170
|
+
|
171
|
+
background-position:center center;
|
172
|
+
|
173
|
+
background-size:cover;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
.cube_left {
|
180
|
+
|
181
|
+
top: 0px;
|
182
|
+
|
183
|
+
-webkit-transform: rotateY(-90deg);
|
184
|
+
|
185
|
+
transform: rotateY(-90deg);
|
186
|
+
|
187
|
+
background-image:url(/test/test1.jpg);
|
188
|
+
|
189
|
+
background-repeat:no-repeat;
|
190
|
+
|
191
|
+
background-position:center center;
|
192
|
+
|
193
|
+
background-size:cover;
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
.nav {
|
200
|
+
|
201
|
+
position: fixed;
|
202
|
+
|
203
|
+
bottom: 0;
|
204
|
+
|
205
|
+
left: 0;
|
206
|
+
|
207
|
+
width: 100%;
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
.nav li {
|
212
|
+
|
213
|
+
float: left;
|
214
|
+
|
215
|
+
width: 20%;
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
.nav li a{
|
220
|
+
|
221
|
+
display: block;
|
222
|
+
|
223
|
+
width: 100%;
|
224
|
+
|
225
|
+
line-height: 40px;
|
226
|
+
|
227
|
+
text-align: center;
|
228
|
+
|
229
|
+
text-decoration: none;
|
230
|
+
|
231
|
+
color: #fff;
|
232
|
+
|
233
|
+
height: 40px;
|
234
|
+
|
235
|
+
background:rgba(0,0,0,0.6);
|
236
|
+
|
237
|
+
font-size: 13px;
|
238
|
+
|
239
|
+
letter-spacing: 3px;
|
240
|
+
|
241
|
+
transition:all 0.5s ease-in-out;
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
```
|
248
|
+
|
249
|
+
```javascript
|
250
|
+
|
251
|
+
$(document).ready(function() {
|
252
|
+
|
253
|
+
var wW = $(window).width();
|
254
|
+
|
255
|
+
var wH = $(window).height();
|
256
|
+
|
257
|
+
var deg = 0;
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
function setCube(){
|
262
|
+
|
263
|
+
// 横回転
|
264
|
+
|
265
|
+
$('.cube').css({'transform':'translateZ(-' + wW/2 +'px)'});
|
266
|
+
|
267
|
+
$('.cube').css({'width' : wW + 'px', 'height': wH + 'px'});
|
268
|
+
|
269
|
+
$('.cube div').css({'width' : wW + 'px', 'height': wH + 'px'});
|
270
|
+
|
271
|
+
$('.cube_left').css({'left' : '-' + wW/2 + 'px'});
|
272
|
+
|
273
|
+
$('.cube_right').css({'right' :'-' + wW/2 + 'px'});
|
274
|
+
|
275
|
+
$('.cube_front').css({'transform':'translateZ(' + wW/2 + 'px)'});
|
276
|
+
|
277
|
+
$('.cube_back').css({'transform':'translateZ(-' + wW/2 + 'px)'});
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
setCube();
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
$(".nav a").click(function(event) {
|
288
|
+
|
289
|
+
// 横回転
|
290
|
+
|
291
|
+
event.preventDefault();
|
292
|
+
|
293
|
+
var moveDeg = $(this).data('deg');
|
294
|
+
|
295
|
+
deg = deg + moveDeg;
|
296
|
+
|
297
|
+
$('.cube').css({'transform':'translateZ(-'+wW/1.5+'px)'});
|
298
|
+
|
299
|
+
setTimeout(function(){
|
300
|
+
|
301
|
+
$('.cube').css({'transform':'translateZ(-'+wW/1.5+'px) rotateY('+moveDeg+'deg)'});
|
302
|
+
|
303
|
+
setTimeout(function(){
|
304
|
+
|
305
|
+
$('.cube').css({'transform':'translateZ(-'+wW/2+'px) rotateY('+moveDeg+'deg)'});
|
306
|
+
|
307
|
+
$('.cube').css({'transform':'rotateY(0deg)'});
|
308
|
+
|
309
|
+
$("#cube1").attr('');
|
310
|
+
|
311
|
+
},1000);
|
312
|
+
|
313
|
+
},500);
|
314
|
+
|
315
|
+
});
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
$(window).on('resize',function(){
|
320
|
+
|
321
|
+
//画面をリサイズした際に各面もリサイズさせる
|
322
|
+
|
323
|
+
setCube();
|
324
|
+
|
325
|
+
});
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
});
|
330
|
+
|
331
|
+
```
|