3
http://codepen.io/Feners4/pen/KggAwgCSSアニメーションに関する問題
私は立方体を360度回転させて回転させたいと思います。私の立方体は軸360度で回転します。アニメーションはすべてクレイジーになり、キューブもまた動かなくなります。どうすればそれらを回転させることができますか?
マイCSS:
@red: rgb(131, 168, 226);
@size: 100px;
body {
background-color: #dff;
}
header {
text-align: center;
}
h1 {
text-align: center;
padding: 9px;
}
.wrap {
perspective: 1000px;
perspective-origin: 46% 70px;
}
.cube {
position: relative;
width: 200px;
transform-style: preserve-3d;
animation: spin 10s linear infinite;
animation-play-state: paused;
animation-direction: alternate;
}
.cube div {
border: 10;
border-style: solid;
border-color: rgb(173, 222, 247);
opacity: .5;
position: absolute;
left: 100px;
width: 200px;
height: 200px;
}
.cube:hover {
animation-play-state: running;
}
@keyframes spin {
5% {
transform: rotateY(360deg);
}
}
.back {
border: 5px solid @red;
outline-style: single;
background: @red;
transform: translateZ(-100px) rotateY(180deg);
}
.right {
opacity: 0.50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateY(-270deg) translateX(87px);
transform-origin: top right;
}
.left {
opacity: 0.50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateY(270deg) translateX(-100px);
transform-origin: center left;
}
.top {
opacity: 0.50;
background: @red;
transform: rotateX(-90deg) translateY(-109px);
transform-origin: top center;
}
.bottom {
opacity: 50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateX(90deg) translateY(109px);
transform-origin: bottom center;
}
.front {
text-align: center;
color: rgb(173, 222, 247);
opacity: 0.50;
border: 2px solid @red;
outline-style: single;
background: @red;
transform: translateZ(109px);
}
.wrap2 {
perspective: 1000px;
perspective-origin: 40% 70px;
}
.cube2 {
position: relative;
width: 100px;
transform-style: preserve-3d;
animation: spin 10s linear infinite;
animation-play-state: paused;
animation-direction: alternate;
}
.cube2 div {
border: 10;
border-style: solid;
border-color: rgb(173, 222, 247);
opacity: .5;
position: absolute;
left: 500px;
width: 200px;
height: 200px;
}
.cube2:hover {
animation-play-state: running;
}
.back2 {
border: 5px solid @red;
outline-style: single;
background: @red;
transform: translateZ(-100px) rotateY(180deg);
}
.right2 {
opacity: 0.50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateY(-90deg) translateX(87px);
transform-origin: top right;
}
.left2 {
opacity: 0.50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateY(90deg) translateX(-100px);
transform-origin: center left;
}
.top2 {
opacity: 0.50;
background: @red;
transform: rotateX(-90deg) translateY(-109px);
transform-origin: top center;
}
.bottom2 {
opacity: 50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateX(90deg) translateY(109px);
transform-origin: bottom center;
}
.front2 {
text-align: center;
opacity: 0.50;
color: rgb(173, 222, 247);
border: 2px solid @red;
outline-style: single;
background: @red;
transform: translateZ(109px);
}
.wrap3 {
perspective: 1000px;
perspective-origin: 110% 70px;
}
.cube3 {
position: relative;
width: 200px;
transform-style: preserve-3d;
animation: spin 10s linear infinite;
animation-play-state: paused;
animation-direction: alternate;
}
.cube3 div {
border: 10;
border-style: solid;
border-color: rgb(173, 222, 247);
opacity: .5;
position: absolute;
left: 999px;
width: 200px;
height: 200px;
}
.cube3:hover {
animation-play-state: running;
}
.back3 {
border: 5px solid @red;
outline-style: single;
background: @red;
transform: translateZ(-110px) rotateY(180deg);
}
.right3 {
opacity: 0.50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateY(-95deg) translateX(110px);
transform-origin: top right;
}
.left3 {
opacity: 0.50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateY(-270deg) translateX(-90px);
transform-origin: center left;
}
.top3 {
opacity: 0.50;
background: @red;
transform: rotateX(-90deg) translateY(-95px);
transform-origin: top center;
}
.bottom3 {
opacity: 50;
border: 5px solid @red;
outline-style: single;
background: @red;
transform: rotateX(92deg) translateY(109px);
transform-origin: bottom center;
}
.front3 {
text-align: center;
color: rgb(173, 222, 247);
opacity: 0.50;
border: 2px solid @red;
outline-style: single;
background: @red;
transform: translateZ(99px);
}
.change-color {
color: #fff;
background-color: #f45642;
cursor: pointer;
}
.change-color:hover,
.change-color:focus,
.change-color:active {
color: #fff;
background-color: #f45642;
cursor: pointer;
}
ご回答いただきありがとうございます。あなたの答えは間違いなく役立ちますが、あなたの方法ではるかに優れているにもかかわらず、キューブはまだその場所に留まらないのです。また、なぜキューブの上に最初にマウスを置くと、アニメーションがすべてクレイジーで本当に速くなるのか分かりません。 – feners
*修正...中間のキューブが所定の位置にとどまりません。左から右にわずかに移動します.. – feners
恐ろしい!あなたの詳細な答えをありがとう。 – feners