Overflow:hidden and border-radius not working with css-animation - css

I'm having trouble with what I believe is a bug in Safari, every other Browser shows it correctly.
http://codepen.io/anon/pen/pvavVa
html looks like this:
<div id="background"></div>
<div id="midground"><div id="baggy"></div></div>
CSS like this:
#keyframes ex4 { /* CSS3 */
0% { -webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
transform: translate(0px, 0px); }
100% { -webkit-transform: translate(0px, -5000px);
-moz-transform: translate(0px, -5000px);
-ms-transform: translate(0px, -5000px);
-o-transform: translate(0px, -5000px);
transform: translate(0px, -5000px); } }
#-moz-keyframes ex4 { /* CSS3 */
0% { -webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
transform: translate(0px, 0px); }
100% { -webkit-transform: translate(0px, -5000px);
-moz-transform: translate(0px, -5000px);
-ms-transform: translate(0px, -5000px);
-o-transform: translate(0px, -5000px);
transform: translate(0px, -5000px); } }
#-webkit-keyframes ex4 { /* CSS3 */
0% { -webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
transform: translate(0px, 0px); }
100% { -webkit-transform: translate(0px, 5000px);
-moz-transform: translate(0px, -5000px);
-ms-transform: translate(0px, -5000px);
-o-transform: translate(0px, -5000px);
transform: translate(0px, -5000px); } }
}
body {
font: 10px/2 "Lucida Grande", Helvetica, Sans-Serif;
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
}
#background {
background: url("http://epicstudios.de/blackwhite/bg2.jpg") fixed repeat;
-webkit-background-size: 100vw auto;
-moz-background-size: 100vw auto;
-o-background-size: 100vw auto;
background-size: 100vw auto;
position: absolute;
background-position:center top;
height:400vh;
top: 0; left: 0; right: 0; bottom: 0;
z-index: 100
;z-index: 199;
animation: ex4 150s infinite; /* CSS3 */
-moz-animation: ex4 150s infinite; /* Firefox */
-webkit-animation: ex4 150s infinite; /* Webkit */
}
#midground {
width:240px;
height:240px;
position:absolute;
left:0px; right:0px;
top:0; bottom:0;
margin:auto;
max-width:100%;
max-height:100%;
overflow:auto;
border-radius:500px;
z-index:200;
overflow:hidden;
-webkit-transition: all 0.7s ease-out;
-moz-transition: all 0.7s ease-out;
-ms-transition: all 0.7s ease-out;
-o-transition: all 0.7s ease-out;
transition: all 0.7s ease-out;
}
#midground:hover {
width:350px;
height:350px;
position:absolute;
left:0px; right:0px;
top:0px; bottom:0;
margin:auto;
max-width:100%;
max-height:100%;
overflow:hidden;
border-radius:0px;
z-index:200;
}
#baggy { background: url(http://epicstudios.de/blackwhite /bg_neg.jpg) repeat fixed;
background-position:center top; -webkit-background-size: 100vw auto;
-moz-background-size: 100vw auto;
-o-background-size: 100vw auto;
background-size: 100vw auto;
background-repeat: repeat-y;
height:600vh;
position:absolute;
left:0; right:0;
top:0; bottom:0;
margin:auto;
overflow:hidden; z-index: 201;animation: ex4 150s infinite; /* CSS3 */
-moz-animation: ex4 150s infinite; /* Firefox */
-webkit-animation: ex4 150s infinite; /* Webkit */
}
The div in the center there should be a Circle, but safari shows a square. In this circle there's a div, that is larger than the circle and is moving because of a css-animation. As soon as I apply this animation to that div, the overflow:hidden and/or the border-radius:50% of the circle-div above it stop working and it appears as a square in safari.
I hope that's clear. I can't use JavaScript for the animation because I tried that before, and it worked, but it proved to be too difficult to process on most computers and the site started lagging and stuttering heavily.
http://codepen.io/anon/pen/pvavVa

Related

CSS - Rotate a shape while maintaining its shape form

I'm pretty comfortable with this solution already but it still makes quite of a shapeshift as it rotates and I wanted to ask you guys if you think of a better solution.
What I want is, given is a hexagon, that starts with one axis up and then rotates to a line at the top,its not what I got but that's just a matter of arranging the rotation accordingly. Since this shape is rendered with multiple divs (found it online not my own) on top of each other that are not visible and covers the main shape so it displays as a hexagon, all the shapes have to rotate at the same time, one thing though is that hexagon-in0 has a different rotation degree than the other, I tried setting up another keyframe with an exact same animation just changing the rotation degree values but did not work, what do you think?
When I posted the code snippet here since I didn't add a background image like in my code I realize it looks like a cube rotating outside-in, kinda cool
.hexagon {
position: relative;
left: 50%;
top: 0%;
transform: translate(-50%, 0%);
cursor: pointer;
visibility: hidden;
width: 400px; /*400*/
height: 200px; /*200*/ }
.hexagon-in0 {
overflow: hidden;
width: 100%;
height: 100%;
-webkit-transform: rotate(120deg);
-moz-transform: rotate(120deg);
-ms-transform: rotate(120deg);
-o-transform: rotate(120deg);
transform: rotate(120deg); }
.hexagon-in1 {
overflow: hidden;
width: 100%;
height: 100%;
animation: rotateHex 5s ease-in 1s forwards;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);}
.hexagon-in2 {
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-position: 50%;
background: rgb(70,243,252);
background: radial-gradient(circle, rgba(70,243,252,1) 0%, rgba(67,28,130,1) 57%);
visibility: visible;
animation: rotateHex 5s ease-in 1s forwards;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);}
#keyframes rotateHex {
0%{
transform: rotate(-120deg);
}
100%{
transform: rotate(-60deg);
}
<div class="hexagon"><div class="hexagon-in0"><div class="hexagon-in1"><div class="hexagon-in2"></div></div></div></div>
Rotate the container instead of each individual piece.
.hexagon {
position: relative;
left: 50%;
top: 0%;
transform: translate(-50%, 0%);
cursor: pointer;
visibility: hidden;
width: 400px; /*400*/
height: 200px; /*200*/
animation: rotateHex 5s ease-in 1s forwards;
}
.hexagon-in0 {
overflow: hidden;
width: 100%;
height: 100%;
-webkit-transform: rotate(120deg);
-moz-transform: rotate(120deg);
-ms-transform: rotate(120deg);
-o-transform: rotate(120deg);
transform: rotate(120deg);
}
.hexagon-in1 {
overflow: hidden;
width: 100%;
height: 100%;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
}
.hexagon-in2 {
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-position: 50%;
background: rgb(70,243,252);
background: radial-gradient(circle, rgba(70,243,252,1) 0%, rgba(67,28,130,1) 57%);
visibility: visible;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);}
#keyframes rotateHex {
0%{
transform: translate(-50%, 0%) rotate(-120deg);
}
100%{
transform: translate(-50%, 0%) rotate(-60deg);
}
<div class="hexagon"><div class="hexagon-in0"><div class="hexagon-in1"><div class="hexagon-in2"></div></div></div></div>

Half or 1/4 spin and return two circles

I have never done animations in CSS, what I'm trying to get is something like cog's animations two circles spinning, one to the right and the other to the left without overlapping...
I think I got the animation(sort of) but not the drawing I think..
I have this demo: https://jsfiddle.net/Tankers/8dxh94zp/9/
the "figures" are correct and the location also correct but the animation is not.
when they spin it overlaps may be is because the object are not 100% squares?, what need to be visible is just half circles just the way that is in my demo..
HTML
<div class="wrap">
<div class="top"></div>
<div class="bott"></div>
</div>
CSS
#keyframes half_spin {
0% {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
40% {
-ms-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
-o-transform: rotate(20deg);
transform: rotate(20deg);
}
60% {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
80% {
-ms-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
-webkit-transform: rotate(-20deg);
-o-transform: rotate(-20deg);
transform: rotate(-20deg);
}
100% {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
}
.wrap {
display: block;
overflow: hidden;
position: relative
}
.top {
width: 300px;
height: 150px;
border: 1px solid red;
border-bottom-left-radius: 151px;
border-bottom-right-radius: 151px;
position: relative;
animation: half_spin 5000ms ease-in-out infinite;
}
.top:before {
position: absolute;
width: 100%;
height: 1px;
background: red;
content: " ";
top: 0;
left: 0;
}
.bott {
width: 300px;
height: 150px;
border: 1px solid black;
border-top-left-radius: 151px;
border-top-right-radius: 151px;
animation: half_spin 5000ms ease-in-out infinite reverse;
position: relative;
}
.bott:before {
position: absolute;
width: 100%;
height: 1px;
background: black;
content: " ";
bottom: 0;
left :0;
}
If I understand your question correctly, this code snippet is what you're looking for. I added a transform-origin property to both the top and bottom half-circles to specify the point that we're rotating around.
Both divs should rotate around the midpoint of their flat edge, for the top that is transform-origin: 50% 0%; and for the bottom it is transform-origin: 50% 100%;
#keyframes half_spin {
0% {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
40% {
-ms-transform: rotate(20deg);
-moz-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
-o-transform: rotate(20deg);
transform: rotate(20deg);
}
60% {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
80% {
-ms-transform: rotate(-20deg);
-moz-transform: rotate(-20deg);
-webkit-transform: rotate(-20deg);
-o-transform: rotate(-20deg);
transform: rotate(-20deg);
}
100% {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
}
.wrap {
display: block;
overflow: hidden;
position: relative
}
.top {
width: 300px;
height: 150px;
border: 1px solid red;
border-bottom-left-radius: 151px;
border-bottom-right-radius: 151px;
position: relative;
animation: half_spin 5000ms ease-in-out infinite;
transform-origin: 50% 0%;
}
.top:before {
position: absolute;
width: 100%;
height: 1px;
background: red;
content: " ";
top: 0;
left: 0;
}
.bott {
width: 300px;
height: 150px;
border: 1px solid black;
border-top-left-radius: 151px;
border-top-right-radius: 151px;
animation: half_spin 5000ms ease-in-out infinite;
position: relative;
transform-origin: 50% 100%;
}
.bott:before {
position: absolute;
width: 100%;
height: 1px;
background: black;
content: " ";
bottom: 0;
left :0;
}
<div class="wrap">
<div class="top">
</div>
<div class="bott">
</div>
</div>

Key frame animation is jerky in ipad both safari and chrome. How to smooth animation in safari?

I have done a ball animation rotation in 360 degree on button click at the same time it moves left and right. It works in chrome and opera perfectly but issues in firefox and iPad devices. In iPad devices animation is so much jerky so how to add smooth animation? In firefox, the number is not showing
$(function(){
$('#genBall').on("click", function () {
$('.eight-ball').addClass("rotate-ball");
setTimeout(RemoveClass, 2000);
});
function RemoveClass() {
$('.eight-ball').removeClass("rotate-ball");
}
});
.eight-ball {
width: 475px;
height: 475px;
overflow: hidden;
position: relative;
border-radius: 50%;
background: #1f84d0;
transform: rotate(12deg);
user-select: none;
display: table;
}
.eight-ball:before {
content: "";
width: 80px;
height: 80px;
background: #fff;
position: absolute;
top: 30px;
left: 40px;
z-index: 999;
opacity: 0.8;
border-radius: 50%;
filter: blur(13px);
}
.eight-ball:after {
content: "";
width: 100%;
height: 100%;
opacity: 0.7;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
border-radius: 50%;
transform: rotate(-137deg);
box-shadow: inset -3px 0 6px 2px rgba(255, 255, 255, 0.2),
inset 50px 0 70px 6px rgba(0, 0, 0, 0.5);
}
.eight-ball-inner-white {
width: 75%;
height: 75%;
overflow: hidden;
margin-top: 55px;
margin-left: 6px;
border-radius: 50%;
position: relative;
display: inline-block;
background: rgb(224,235,245);
background: -moz-linear-gradient(top, rgba(224,235,245,1) 0%, rgba(190,205,214,1) 100%);
background: -webkit-linear-gradient(top, rgba(224,235,245,1) 0%,rgba(190,205,214,1) 100%);
background: linear-gradient(to bottom, rgba(224,235,245,1) 0%,rgba(190,205,214,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0ebf5', endColorstr='#becdd6',GradientType=0 );
}
.rotate-ball {
-webkit-animation: rotateanim ease-in-out 2s;
-moz-animation: rotateanim ease-in-out 2s;
-ms-animation: rotateanim ease-in-out 2s;
-o-animation: rotateanim ease-in-out 2s;
animation: rotateanim ease-in-out 2s;
}
#-webkit-keyframes rotateanim {
0% {margin-left: 0px; transform: rotate(12deg); -webkit-transform: rotate(12deg); -moz-transform: rotate(12deg); -o-transform: rotate(12deg); -ms-transform: rotate(12deg);}
30% {margin-left: 340px; transform: rotate(205deg); -webkit-transform: rotate(205deg); -moz-transform: rotate(205deg); -o-transform: rotate(205deg); -ms-transform: rotate(205deg);}
50% {margin-left: -340px; transform: rotate(-320deg); transform: rotate(-320deg); -webkit-transform: rotate(-320deg); -moz-transform: rotate(-320deg); -o-transform: rotate(-320deg); -ms-transform: rotate(-320deg);}
100% {margin-left: 0px; transform: rotate(12deg); transform: rotate(12deg); -webkit-transform: rotate(12deg); -moz-transform: rotate(12deg); -o-transform: rotate(12deg); -ms-transform: rotate(12deg);}
}
#keyframes rotateanim {
0% {margin-left: 0px; transform: rotate(12deg); -webkit-transform: rotate(12deg); -moz-transform: rotate(12deg); -o-transform: rotate(12deg); -ms-transform: rotate(12deg);}
30% {margin-left: 340px; transform: rotate(205deg); -webkit-transform: rotate(205deg); -moz-transform: rotate(205deg); -o-transform: rotate(205deg); -ms-transform: rotate(205deg);}
50% {margin-left: -340px; transform: rotate(-320deg); transform: rotate(-320deg); -webkit-transform: rotate(-320deg); -moz-transform: rotate(-320deg); -o-transform: rotate(-320deg); -ms-transform: rotate(-320deg);}
100% {margin-left: 0px; transform: rotate(12deg); transform: rotate(12deg); -webkit-transform: rotate(12deg); -moz-transform: rotate(12deg); -o-transform: rotate(12deg); -ms-transform: rotate(12deg);}
}
.eight-ball-inner-white span {
color: #222b32;
position: absolute;
top: 50%;
left: 50%;
font-size: 140px;
font-weight: bold;
transition: all ease 1s;
transform: translate(-50%,-50%);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="eight-ball">
<div class="eight-ball-inner-white spin-ball">
<span>GO</span>
</div>
</div>
<button id="genBall">play</button>
Finally, I found the solution. Added extra div after eightball class. Instead of giving rotation and movement to one div give separate animation to both div. Use movement to the main div and use rotation to child
$(function(){
$('#genBall').on("click", function () {
$('.eight-ball').addClass("rotate-ball");
setTimeout(RemoveClass, 2000);
});
function RemoveClass() {
$('.eight-ball').removeClass("rotate-ball");
}
});
.eight-ball {
width: 475px;
height: 475px;
overflow: hidden;
position: relative;
border-radius: 50%;
background: #1f84d0;
user-select: none;
display: table;
}
.eight-ball>div {
width: 100%;
height: 100%;
}
.eight-ball>div:before {
content: "";
width: 80px;
height: 80px;
background: #fff;
position: absolute;
top: 30px;
left: 40px;
z-index: 999;
opacity: 0.8;
border-radius: 50%;
filter: blur(13px);
}
.eight-ball:after {
content: "";
width: 100%;
height: 100%;
opacity: 0.7;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
border-radius: 50%;
transform: rotate(-137deg);
box-shadow: inset -3px 0 6px 2px rgba(255, 255, 255, 0.2), inset 50px 0 70px 6px rgba(0, 0, 0, 0.5);
}
.eight-ball-inner-white {
width: 75%;
height: 75%;
overflow: hidden;
margin-top: 55px;
margin-left: 6px;
border-radius: 50%;
position: relative;
display: inline-block;
transform: rotate(12deg);
background: rgb(224, 235, 245);
background: -moz-linear-gradient(top, rgba(224, 235, 245, 1) 0%, rgba(190, 205, 214, 1) 100%);
background: -webkit-linear-gradient(top, rgba(224, 235, 245, 1) 0%, rgba(190, 205, 214, 1) 100%);
background: linear-gradient(to bottom, rgba(224, 235, 245, 1) 0%, rgba(190, 205, 214, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e0ebf5', endColorstr='#becdd6', GradientType=0);
}
.rotate-ball {
-webkit-animation: rotateanim ease-in-out 2s;
-moz-animation: rotateanim ease-in-out 2s;
-ms-animation: rotateanim ease-in-out 2s;
-o-animation: rotateanim ease-in-out 2s;
animation: rotateanim ease-in-out 2s;
}
.rotate-ball>div {
-webkit-animation: rotateanimInner ease-in-out 2s;
-moz-animation: rotateanimInner ease-in-out 2s;
-ms-animation: rotateanimInner ease-in-out 2s;
-o-animation: rotateanimInner ease-in-out 2s;
animation: rotateanimInner ease-in-out 2s;
}
#-webkit-keyframes rotateanim {
0% {
transform: translate(0px, 0px);
-webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
}
30% {
transform: translate(340px, 0px);
-webkit-transform: translate(340px, 0px);
-moz-transform: translate(340px, 0px);
-o-transform: translate(340px, 0px);
-ms-transform: translate(340px, 0px);
}
50% {
transform: translate(-340px, 0px);
-webkit-transform: translate(-340px, 0px);
-moz-transform: translate(-340px, 0px);
-o-transform: translate(-340px, 0px);
-ms-transform: translate(-340px, 0px);
}
100% {
transform: translate(0px, 0px);
-webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
}
}
#keyframes rotateanim {
0% {
transform: translate(0px, 0px);
-webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
}
30% {
transform: translate(340px, 0px);
-webkit-transform: translate(340px, 0px);
-moz-transform: translate(340px, 0px);
-o-transform: translate(340px, 0px);
-ms-transform: translate(340px, 0px);
}
50% {
transform: translate(-340px, 0px);
-webkit-transform: translate(-340px, 0px);
-moz-transform: translate(-340px, 0px);
-o-transform: translate(-340px, 0px);
-ms-transform: translate(-340px, 0px);
}
100% {
transform: translate(0px, 0px);
-webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
}
}
#-webkit-keyframes rotateanimInner {
0% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
}
30% {
transform: rotate(205deg);
-webkit-transform: rotate(205deg);
-moz-transform: rotate(205deg);
-o-transform: rotate(205deg);
-ms-transform: rotate(205deg);
}
50% {
transform: rotate(-320deg);
-webkit-transform: rotate(-320deg);
-moz-transform: rotate(-320deg);
-o-transform: rotate(-320deg);
-ms-transform: rotate(-320deg);
}
100% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
}
}
#keyframes rotateanimInner {
0% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
}
30% {
transform: rotate(205deg);
-webkit-transform: rotate(205deg);
-moz-transform: rotate(205deg);
-o-transform: rotate(205deg);
-ms-transform: rotate(205deg);
}
50% {
transform: rotate(-320deg);
-webkit-transform: rotate(-320deg);
-moz-transform: rotate(-320deg);
-o-transform: rotate(-320deg);
-ms-transform: rotate(-320deg);
}
100% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
}
}
.eight-ball-inner-white span {
color: #222b32;
position: absolute;
top: 50%;
left: 50%;
font-size: 140px;
font-weight: bold;
transition: all ease 1s;
transform: translate(-50%, -50%);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="eight-ball">
<div>
<div class="eight-ball-inner-white spin-ball">
<span id="bingoBalls">55</span>
</div>
</div>
</div>
<button id="genBall">play</button>

CSS cube wobbling when rotating

Trying to make a cube that spins but it wobbles up and down when it rotates think its got something to do with transform origin. Tried messing around with different values for the cube but it only becomes more exaggerated.
/* Chrome, Safari, Opera */
#keyframes spin-vertical
{
0% { -webkit-transform: rotateX(0); }
100% { -webkit-transform: rotateX(-360deg); }
}
/* Standard syntax */
#-webkit-keyframes spin-vertical
{
0% { -webkit-transform: rotateX(0); }
100% { -webkit-transform: rotateX(-360deg); }
}
body
{
font: normal 30px "HelveticaNeue-Light", sans-serif;
}
.wrapper
{
margin: 200px;
background-color: black;
}
.face
{
background-color: black;
color: white;
padding: 2px 5px;
position: absolute;
width: 300px;
}
.cube
{
position: relative;
-webkit-transform-style: preserve-3d;
-webkit-animation: spin-vertical 5s infinite linear;
-moz-transform-origin: 10px 18px;
-ms-transform-origin: 10px 18px;
-o-transform-origin: 10px 18px;
-webkit-transform-origin: 10px 18px;
transform-origin: 10px 18px;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
-webkit-transition: all 0.5s;
transition: all 0.5s;
margin: 0 auto;
}
#top
{
-moz-transform: rotatex(-270deg) translatey(-40px);
-ms-transform: rotatex(-270deg) translatey(-40px);
-o-transform: rotatex(-270deg) translatey(-40px);
-webkit-transform: rotatex(-270deg) translatey(-40px);
transform: rotatex(-270deg) translatey(-40px);
-moz-transform-origin: top center;
-ms-transform-origin: top center;
-o-transform-origin: top center;
-webkit-transform-origin: top center;
transform-origin: top center
}
#bottom
{
-moz-transform: rotatex(90deg) translatey(0);
-ms-transform: rotatex(90deg) translatey(0);
-o-transform: rotatex(90deg) translatey(0);
-webkit-transform: rotatex(90deg) translatey(0);
transform: rotatex(90deg) translatey(0);
-moz-transform-origin: bottom center;
-ms-transform-origin: bottom center;
-o-transform-origin: bottom center;
-webkit-transform-origin: bottom center;
transform-origin: bottom center
}
#back
{
-moz-transform: translatez(-40px) rotatex(-180deg);
-ms-transform: translatez(-40px) rotatex(-180deg);
-o-transform: translatez(-40px) rotatex(-180deg);
-webkit-transform: translatez(-40px) rotatex(-180deg);
transform: translatez(-40px) rotatex(-180deg)
}
#front
{
-moz-transform: translatez(40px);
-ms-transform: translatez(40px);
-o-transform: translatez(40px);
-webkit-transform: translatez(40px);
transform: translatez(40px)
}
<body>
<div class="wrapper">
<div class="cube" id="cuberotate">
<div class="face" id="front">FACE 1</div>
<div class="face" id="top">FACE 4</div>
<div class="face" id="bottom">FACE 2</div>
<div class="face" id="back">FACE 3</div>
</div>
</div>
</body>
JSFiddle: https://jsfiddle.net/w1kc28zp/
Any advice would be great.
Done some updates to how the sides are transformed, also you're right about transform-origin. On the cube element it should be "0 20px" where 20px stands for 50% of the height of each side.
See result at: https://jsfiddle.net/w1kc28zp/1/
.cube {
margin: 0 auto;
width:300px;
position:relative;
-webkit-transform-style: preserve-3d;
-webkit-transform-origin:0 20px;
-webkit-animation: spin-vertical 5s infinite linear;
}
#front {
-webkit-transform: translateZ(20px);
}
#top {
transform: rotateX(-270deg) translateY(-20px);
transform-origin:top center;
}
#back {
transform: translateZ(-20px) rotateX(180deg);
}
#bottom {
transform: rotateX(-90deg) translateY(20px);
transform-origin:bottom center;
}

Animate a background image ease-in-out in CSS?

I am trying to make a background image smoothly fade in when the class is added and fade out when the class is removed (to a div).
My current CSS (tested in Firefox only)
background : url("/PmDojo/dojox/widget/Standby/images/loading.gif");
-moz-transition : background 0.5s ease-in-out;
background-repeat: no-repeat;
background-position: 65px center;
background-size: "contain";
But what that does is show the image fade in and move to the center from the left. I want it to already be in position when the fading in happens. How?
Hard to tell without seeing your class and javascript but, from my experience with css3 transitions and animations - all of the elements in the class with the transition/animation on it are taken into effect. So you will want to have two classes to seperate the static css properties from the animating ones. Put these properties on another class for that div which is always present:
-moz-transition : background 0.5s ease-in-out;
background-repeat: no-repeat;
background-position: 65px center;
background-size: "contain";
Then just toggle the class which has the animation properties:
background : url("/PmDojo/dojox/widget/Standby/images/loading.gif");
So when you change the class you have say "defaultClass" class to start and then change it to "default animationClass" for toggling the animation/transition. Hope that helps?
Try this link with this answer. Also check out this answer, cause it may well be possible to do this with jquery.
If not, last resort may be to just position an image with z-index below all your other layers and then animate it as a regular DOM element.
maybe the question is closed, but i'll try to post my answer
this code should work, just use your own bg.jpg
<html>
<head>
<title>some title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"><style>
#bg {
-moz-animation: bg 60s linear infinite;
-webkit-animation: bg 60s linear infinite;
-o-animation: bg 60s linear infinite;
-ms-animation: bg 60s linear infinite;
animation: bg 60s linear infinite;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-o-backface-visibility: hidden;
-ms-backface-visibility: hidden;
/*backface-visibility: hidden;*/ //ORIGIN
backface-visibility: visible;
-moz-transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
/* Set your background with this */
background: #348cb2 url("images/bg.jpg") bottom left;
background-repeat: repeat-x;
height: 100vh;
left: 0;
opacity: 1;
position: fixed;
top: 0;
}
#-moz-keyframes bg { 0% { -moz-transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); -o-transform: translate3d(0,0,0); -ms-transform: translate3d(0,0,0); transform: translate3d(0,0,0); } 100% { -moz-transform: translate3d(-2250px,0,0); -webkit-transform: translate3d(-2250px,0,0); -o-transform: translate3d(-2250px,0,0); -ms-transform: translate3d(-2250px,0,0); transform: translate3d(-2250px,0,0); } }
#-webkit-keyframes bg { 0% { -moz-transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); -o-transform: translate3d(0,0,0); -ms-transform: translate3d(0,0,0); transform: translate3d(0,0,0); } 100% { -moz-transform: translate3d(-2250px,0,0); -webkit-transform: translate3d(-2250px,0,0); -o-transform: translate3d(-2250px,0,0); -ms-transform: translate3d(-2250px,0,0); transform: translate3d(-2250px,0,0); } }
#-o-keyframes bg { 0% { -moz-transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); -o-transform: translate3d(0,0,0); -ms-transform: translate3d(0,0,0); transform: translate3d(0,0,0); } 100% { -moz-transform: translate3d(-2250px,0,0); -webkit-transform: translate3d(-2250px,0,0); -o-transform: translate3d(-2250px,0,0); -ms-transform: translate3d(-2250px,0,0); transform: translate3d(-2250px,0,0); } }
#-ms-keyframes bg { 0% { -moz-transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); -o-transform: translate3d(0,0,0); -ms-transform: translate3d(0,0,0); transform: translate3d(0,0,0); } 100% { -moz-transform: translate3d(-2250px,0,0); -webkit-transform: translate3d(-2250px,0,0); -o-transform: translate3d(-2250px,0,0); -ms-transform: translate3d(-2250px,0,0); transform: translate3d(-2250px,0,0); } }
#keyframes bg { 0% { -moz-transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); -o-transform: translate3d(0,0,0); -ms-transform: translate3d(0,0,0); transform: translate3d(0,0,0); } 100% { -moz-transform: translate3d(-2250px,0,0); -webkit-transform: translate3d(-2250px,0,0); -o-transform: translate3d(-2250px,0,0); -ms-transform: translate3d(-2250px,0,0); transform: translate3d(-2250px,0,0); } }
#bg {
background-size: 2250px auto;
width: 6750px;
}</style>
</head>
<body>
<div id="bg"></div>
</body></html>

Resources