Move Image across using CSS3 animation - html

I am trying to slide an image across the screen and then stay at a fixed point. I have looked online and found a few variants on what I have but nothing seems to work.

Have a look at this fiddle.
http://jsfiddle.net/lharby/ysgzpuer/
I had to pass in
-webkit-animation: mini 2s normal;
-moz-animation: mini 3s normal;
-o-animation: mini 3s normal;
animation: mini 2s normal;
to the .mini class to animate the div.
Update: This also has the opacity animated:
http://jsfiddle.net/lharby/ysgzpuer/1/
By editing:
#-webkit-keyframes mini {
from {
left:0px;
opacity:0;
}
to{
left:404px;
opacity:1;
}

#-webkit-keyframes mini {
from {
left:-166px;
}
}
.mini {
background-image: url("http://placehold.it/150x150");
position: absolute;
top: 10px;
left: 404px;
width: 166px;
height: 70px;
z-index: 7;
-webkit-animation: mini 2s linear;
}
<div class=mini></div>
Or this if you don't have overflow: hidden on the parent to avoid the scrollbar
#-webkit-keyframes mini {
from {
left:0px;
-webkit-transform: translateX(-166px)
}
}
.mini {
background-image: url("http://placehold.it/150x150");
position: absolute;
top: 10px;
left: 404px;
width: 166px;
height: 70px;
z-index: 7;
-webkit-animation: mini 2s linear;
}
<div class=mini></div>

this will keep the last frame of the animation after its done
animation-fill-mode: forwards;
#-webkit-keyframes mini {
from{
opacity:0;
}
to{
opacity:1;
}
from {
left:0px;
}
to{
left:404px;
}
}
.frame1 {
-webkit-animation: mini 2s normal forwards;
-moz-animation: mini 30s normal forwards;
-o-animation: mini 30s normal forwards;
animation: mini 2s normal forwards;
opacity:1;
}
.mini {
background-image: url("http://blog.grio.com/wp-content/uploads/2012/09/stackoverflow.png");
position: absolute;
top: 10px;
left: -404px;
width: 166px;
height: 70px;
z-index: 7;
}
<div class="frame1 mini">
</div>

hope this is what you are looking for
Html
<div class="stage">
<figure class="ball"></figure>
</div>
CSS
#keyframes slide {
0% {
left: 0;
top: 0;
}
100% {
left: 488px;
top: 0;
}
}
.stage {
background: #eaeaed;
border-radius: 6px;
height: 150px;
position: relative;
min-width: 538px;
}
.stage:hover .ball {
animation-name: slide;
animation-duration: 2s;
animation-timing-function: ease-in-out;
animation-delay: .5s;
animation-fill-mode: forwards;
}
.stage:active .ball {
animation-play-state: paused;
}
.ball {
background: #2db34a;
border-radius: 50%;
height: 50px;
position: absolute;
width: 50px;
}
Fiddle Demo

Related

Css Animations: trial to mvoe a div element up and down and simultaneously rotating the img element inside it fails

Project Description: I am in quest to apply two animations to a nested images inside a div that actually The Div has the responsibility to move the image up and down because the image is captivated inside it And the image(img) which is nested inside the div, Has the responsibility to rotate successively while the div is bouncing the image up and down.
What I want:
1.the image inside the div should keep rotating 360 degrees
2.While the 1 is happening, The div should keep bouncing or moving up and down
.ground {
position: absolute;
width: 100%;
height: 20px;
background-color: gray;
top: 800px;
}
.ball-container {
position: relative;
width 100px;
height: 100px;
left: 50%;
animation-name: bounce;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-direction: forwards;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
#keyframes bounce{
0% {
top: 0px;
}
50% {
top: 700px;
width: 130px;
height: 70px;
}
100% {
top: 0px;
}
}
img {
position: absolute;
width: 100px;
height: 100px;
animation-name: rotation;
animation-direction: forwards;
animation-duration: 1s;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
}
#keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
<html>
<div class="ball-container" id="ball-container"><img src="https://image.flaticon.com/icons/svg/53/53283.svg" alt="ball" class="ball" id="ball"/>
</div>
<div class="ground"></div>
</html>
The problem: the bouncing process is awesome, but I dont know how to make the image rotating while it is bouncing.
Thanks.
Codepen Link
THE POST IS EDITED AND HAS NO PROBLEM AFTER APPLYING THE ANSWER
animation-iteration-count should be infinite on img rotation, to match the number of times it bounces as well, else the animation will run once and stop while the box is still bouncing. Also you have a typo, the semicolon in to {transform: rotate(360deg;)} should be outside to {transform: rotate(360deg);}. This is why it doesnt work.
Furthermore animation-direction:forwards is invalid, the correct value is animation-direction:normal.
With these corrections the code is:
.ground {
position: absolute;
width: 100%;
height: 20px;
background-color: gray;
top: 800px;
}
.ball-container {
position: relative;
width 100px;
height: 100px;
left: 50%;
animation-name: bounce;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-direction: normal;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
#keyframes bounce{
0% {
top: 0px;
}
50% {
top: 700px;
width: 130px;
height: 70px;
}
100% {
top: 0px;
}
}
img {
position: absolute;
width: 100px;
height: 100px;
animation-name: rotation;
animation-direction: normal;
animation-duration: 1s;
animation-timing-function: linear;
animation-fill-mode: both;
animation-iteration-count: infinite;
}
#keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
<html>
<div class="ball-container" id="ball-container"><img src="https://image.flaticon.com/icons/svg/53/53283.svg" alt="ball" class="ball" id="ball"/>
</div>
<div class="ground"></div>
</html>

Keyframe css animation

Question
let's if i have the following example
A-------------B------------C
how i can start an animation from the middle ( B ) then it go to A then to B and finaly it go to C , i made an example but it's not working good.
Code
.container {
display: block;
}
.container .line {
display: block;
height: 1px;
width: 400px;
background: red;
}
.line:after{
content: "";
height: 20px;
width: 20px;
display: block;
background: black;
border-radius: 50%;
position: absolute;
left: 200px;
top: 0px;
}
#keyframes move {
0% {
left: 200px;
}
25%{
left: 0px;
}
100%{
left: 400px;
}
}
.line:after {
-webkit-animation: move 1s alternate infinite;
-moz-animation: move 1s alternate infinite;
-ms-animation: move 1s alternate infinite;
-o-animation: move 1s alternate infinite;
animation: move 1s alternate infinite;
}
<div class="container">
<div class="line"></div>
</div>
If you do it this way, I thinks it's working well.
In stead of alternate I did use linear. It makes the animation smoother.
.container {
display: block;
}
.container .line {
display: block;
height: 1px;
width: 400px;
background: red;
}
.line:after{
content: "";
height: 20px;
width: 20px;
display: block;
background: black;
border-radius: 50%;
position: absolute;
left: 200px;
top: 0px;
}
#keyframes move {
0% {
left: 200px;
}
25%{
left: 0px;
}
75%{
left: 400px;
}
100%{
left: 200px;
}
}
.line:after {
-webkit-animation: move linear 1s infinite;
-moz-animation: move linear 1s infinite;
-ms-animation: move linear 1s infinite;
-o-animation: move linear 1s infinite;
animation: move linear 1s infinite;
}
<div class="container">
<div class="line"></div>
</div>
You could do it like this, also if add linear (because default is ease) you will get something like this Fiddle
.container .line {
height: 1px;
width: 400px;
background: red;
}
.line:after{
content: "";
height: 20px;
width: 20px;
background: black;
border-radius: 50%;
position: absolute;
left: 200px;
top: 0px;
animation: move 3s infinite;
}
#keyframes move {
0% {left: 200px;}
25%{left: 0px;}
50% {left: 200px;}
75% {left: 400px;}
100%{left: 200px;}
}
<div class="container">
<div class="line"></div>
</div>

Css - Multi Animated Progress Bar with Different Progress Percentages

I have an Animated Progress Bar that works fine, but I want to have more than one with different percentages I have had a go at this with no look I have added a jsfiddle below.
Jsfiddle Demo: https://jsfiddle.net/8sja2577/
<p><span class="subtitle"><h3>bar1</h3></span></p>
<div id="progressbar"><div id="other" ><div id="pbaranim"></div></div></div>
<p><span class="subtitle"><h3>bar2</h3></span></p>
<div id="progressbar"><div id="progress" ><div id="pbaranim"></div></div></div>
CSS
#progressbar {
width: 100%;
height: 21px;
background-color: #ccc;
padding: 2px;
margin: .6em 0;
border: 1px #000 double;
clear: both;
border-radius:20px;
}
#progress {
border-radius:20px;
background: red; /*-- Color of the bar --*/
height: 15px;
width: 0%;
max-width: 100%;
float: left;
-webkit-animation: progress 2s 1 forwards;
-moz-animation: progress 2s 1 forwards;
-ms-animation: progress 2s 1 forwards;
animation: progress 2s 1 forwards;
}
#other {
border-radius:20px;
background: red; /*-- Color of the bar --*/
height: 15px;
width: 0%;
max-width: 100%;
float: left;
-webkit-animation: progress 2s 1 forwards;
-moz-animation: progress 2s 1 forwards;
-ms-animation: progress 2s 1 forwards;
animation: progress 2s 1 forwards;
}
#pbaranim {
height: 15px;
width: 100%;
overflow: hidden;
background: url('http://www.cssdeck.com/uploads/media/items/7/7uo1osj.gif') repeat-x;
-moz-opacity: 0.25;
-khtml-opacity: 0.25;
opacity: 0.25;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=25);
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=25);
filter: alpha(opacity=25);
#-webkit-keyframes other { from { } to { width: 100% }}
#-moz-keyframes other { from { } to { width: 100% }}
#-ms-keyframes other { from { } to { width: 100% }}
#keyframes other { from { } to { width: 100% }}
#-webkit-keyframes progress { from { }to { width: 36% }}
#-moz-keyframes progress { from { } to { width: 36% }}
#-ms-keyframes progress { from { } to { width: 36% }}
#keyframes progress { from { } to { width: 36% }}
You need to change the other style to use the other animation:
#other {
border-radius:20px;
background: red;
height: 15px;
width: 0%;
max-width: 100%;
float: left;
-webkit-animation: other 2s 1 forwards;
-moz-animation: other 2s 1 forwards;
-ms-animation: other 2s 1 forwards;
animation: other 2s 1 forwards;
}
Fixed fiddle (using classes instead of ids)
Please note that ids should be unique and h3 cannot be a child of either a p or a span
Id of progressbars is uniqe , you must change other progressbars id to work it successfully

CSS Image animation works in all browsers BUT safari

I am using CSS to flip images to make them look like they flip in.
This works in all browsers but safari. Please open this link in chrome or firefox where it appears correctly, then please open it in safari:
http://project-awesome.id-staging.com/SO-test/index.html
Here is my CSS:
KEYFRAMES
#-moz-keyframes spin { 100% {opacity:1; -moz-transform: rotateY(180deg); } }
#-webkit-keyframes spin { 100% {opacity:1; -webkit-transform: rotateY(180deg); } }
#keyframes spin { 100% {opacity:1; -webkit-transform: rotateY(180deg); transform:rotateY(180deg); } }
#-moz-keyframes spin2 { 100% {opacity:1; -moz-transform: rotateY(180deg); } }
#-webkit-keyframes spin2 { 100% {opacity:1; transform:rotateY(-180deg); -webkit-transform-origin:100% 0 0; transform-origin:100% 0 0; } }
#keyframes spin2 { 100% {opacity:1; transform:rotateY(-180deg); -webkit-transform-origin:100% 0 0; transform-origin:100% 0 0; } }
#-moz-keyframes spin3 { 100% { opacity:1; transform:rotateX(-180deg); -webkit-transform-origin:0 100% 0; transform-origin:0 100% 0; } }
#-webkit-keyframes spin3 { 100% { opacity:1; transform:rotateX(-180deg); -webkit-transform-origin:0 100% 0; transform-origin:0 100% 0; } }
#keyframes spin3 { 100% { opacity:1; transform:rotateX(-180deg); -webkit-transform-origin:0 100% 0; transform-origin: 0 100% 0; } }
#-moz-keyframes spin5 { 100% { opacity:1; transform:rotateX(180deg); -webkit-transform-origin: 0 0 100% 0; transform-origin:100% 0 0 } }
#-webkit-keyframes spin5 { 100% { opacity:1; transform:rotateX(180deg); -webkit-transform-origin:0 0 100% 0; transform-origin:0 0 100% 0; } }
#keyframes spin5 { 100% { opacity:1; transform:rotateX(180deg); -webkit-transform-origin: 0 0 100% 0 ; transform-origin: 0 0 100% 0; } }
#-moz-keyframes spin4 { 100% {opacity:1; -moz-transform: rotateY(-180deg); } }
#-webkit-keyframes spin4 { 100% {opacity:1; transform:rotateY(-180deg); -webkit-transform-origin:100% 0 0; transform-origin:0 100% 0; } }
#keyframes spin4 { 100% {opacity:1; transform:rotateY(-180deg); -webkit-transform-origin:100% 0 0; transform-origin:0 100% 0; } }
Each image flip:
.front-1 {
position: absolute;
left: -65px;
top: 54px;
width: 72px;
height: 72px;
opacity:0;
-webkit-animation:spin2 0.5s 0.5s linear forwards;
-moz-animation:spin2 0.5s 0.5s linear forwards;
animation:spin2 0.5s 0.5s linear forwards;
}
.front-2 {
position: absolute;
left: 7px;
top: 54px;
width: 72px;
height: 72px;
z-index:-94;
opacity:0;
-webkit-animation:spin2 0.5s 1.2s linear forwards;
-moz-animation:spin2 0.5s 1.2s linear forwards;
animation:spin2 0.5s 1.2s linear forwards;
}
.front-3 {
position: absolute;
left: -65px;
top: 374px;
width: 72px;
height: 72px;
opacity:0;
-webkit-animation:spin2 0.5s 1.5s linear forwards;
-moz-animation:spin2 0.5s 1.5s linear forwards;
animation:spin2 0.5s 1.5s linear forwards;
}
.front-4 {
position: absolute;
left: 7px;
top: 374px;
width: 72px;
height: 72px;
z-index:-95;
opacity:0;
-webkit-animation: spin2 0.5s 2.0s linear forwards;
-moz-animation:spin2 0.5s 2.0s linear forwards;
animation:spin2 0.5s 2.0s linear forwards;
}
.front-5 {
position: absolute;
left: 79px;
top: 446px;
width: 72px;
height: 72px;
opacity:0;
}
.front-6 {
position: absolute;
left: 79px;
top: 374px;
width: 72px;
height: 72px;
z-index:-96;
opacity: 0;
-webkit-animation:spin3 0.5s 2.5s linear forwards;
-moz-animation:spin3 .0.5s 2.5s linear forwards;
animation:spin3 0.5s 2.5s linear forwards;
}
.front-7 {
position: absolute;
left: 79px;
top: 518px;
width: 72px;
height: 72px;
z-index:-99;
opacity:0;
-webkit-animation:spin4 0.5s 3.5s linear forwards;
-moz-animation:spin4 0.5s 3.5s linear forwards;
animation:spin4 0.5s 3.5s linear forwards;
}
.front-8 {
position: absolute;
left: 79px;
top: 446px;
width: 72px;
height: 72px;
z-index:-98;
opacity:0;
-webkit-animation:spin3 0.5s 3.0s linear forwards;
-moz-animation:spin3 0.5s 3.0s linear forwards;
animation:spin3 0.5s 3.0s linear forwards;
}
/* BACK IMAGE CLASSES */
.back-1 {
position: absolute;
left: 79px;
top: 54px;
width: 72px;
height: 72px;
opacity:0;
-webkit-animation:spin 0.5s 7s linear forwards;
-moz-animation:spin 0.5s 7s linear forwards;
animation:spin 0.5s 7s linear forwards;
}
.back-2 {
position: absolute;
left: 79px;
top: 54px;
width: 72px;
height: 72px;
opacity:0;
}
.back-3 {
position: absolute;
left: 79px;
top: 374px;
width: 72px;
height: 72px;
opacity:0;
-webkit-animation:spin4 0.5s 5.5s linear forwards;
-moz-animation:spin4 0.5s 5.5s linear forwards;
animation:spin4 0.5s 5.5s linear forwards;
}
.back-4 {
position: absolute;
left: 79px;
top: 374px;
width: 72px;
height: 72px;
opacity:0;
-webkit-animation:spin5 0.5s 6s linear forwards;
-moz-animation:spin5 0.5s 6s linear forwards;
animation:spin5 0.5s 6s linear forwards;
}
.back-5 {
position: absolute;
left: 7px;
top: 446px;
width: 72px;
height: 72px;
opacity:0;
}
.back-6 {
position: absolute;
left: 79px;
top: 446px;
width: 72px;
height: 72px;
opacity:0;
-webkit-animation:spin5 0.5s 4.5s linear forwards;
-moz-animation:spin5 0.5s 4.5s linear forwards;
animation:spin5 0.5s 4.5s linear forwards;
}
.back-7 {
position: absolute;
left: 7px;
top: 518px;
width: 72px;
height: 72px;
opacity:0;
z-index:80;
-webkit-animation:spin 0.5s 4s linear forwards;
-moz-animation:spin 0.5s 4s linear forwards;
animation:spin 0.5s 4s linear forwards;
}
.back-8 {
position: absolute;
left: 7px;
top: 518px;
width: 72px;
height: 72px;
opacity:0;
z-index:-81;
-webkit-animation:spin2 0.5s 5s linear forwards;
-moz-animation:spin2 0.5s 5s linear forwards;
animation:spin2 0.5s 5s linear forwards;
}
Any ideas are highly appreciated.
Thanks in advance
you forgot the -webkit- prefix in some of your transforms in the #-webkit-keyframes blocks.
i wont go over everything, but you should lookup sections like this:
#-webkit-keyframes spin2 {
100% {
opacity:1;
transform:rotateY(-180deg);
-webkit-transform-origin:100% 0 0;
transform-origin:100% 0 0;
}
}
and add the -webkit- prefix to the rotation transformation as well.

CSS Animation not working

Here is the code, I really dont understand what is wrong.
I also tried using -webkit- but did not make any difference trying to move the objects accross the screen, simple animation
HTML:
<body>
<h1 class='cloud'>
SKILLS
</h1>
<h1 class='balloon'>
WORKS
</h1>
</body>
CSS:
.cloud {
background: url(../image/cloudskills.svg)no-repeat;
height:100px;
width:130px;
text-indent: -999em;
animation: cloud 5s linear infinite;
-webkit-animation: cloud 5s linear infinite;
}
#-webkit-keyframes cloud {
0%, 100% {
left: 0%;
}
50% {
left: 100%;
}
}
.balloon {
background: url(../image/balloonworks.svg)no-repeat;
width: 100px;
height: 130px;
text-indent: -999em;
animation: balloon 5s linear infinite;
}
#keyframes balloon{
0%, 100% {
left: 0%;
}
50% {
left: 100%;
}
}
Js Fiddle
for the elements to make some animation position should be given so aboslute or relative or you can use margin in keyframes to move the element
.cloud {
background: url(http://cdn.flaticon.com/png/256/8800.png)no-repeat;
height:100px;
width:130px;
background-size:100px auto;
text-indent: -999em;
animation: cloud 5s linear infinite;
-webkit-animation: cloud 5s linear infinite;
position:relative;
}
#-webkit-keyframes cloud {
0%, 100% {
left: 0%;
}
50% {
left: 100%;
}
}
.balloon {
background: url(http://cdn.flaticon.com/png/256/8800.png)no-repeat;
background-size:100px auto;
width: 100px;
height: 130px;
text-indent: -999em;
animation: cloud 5s linear infinite;
-webkit-animation: cloud 5s linear infinite;
position:relative;
}
#-webkit-keyframes balloon {
0%, 100% {
left: 0%;
}
50% {
left: 100%;
}
}
I changed only a bit of your code http://jsfiddle.net/2gbngtxp/
#-webkit-keyframes cloud {
0% {
left: 0;
}
50% {
margin-left: 100%; /*changed 'left:100%' to 'margin-left:100%'*/
}
100%{
left:0;
}