Multiple keyframes animations - html

I want an arrow first to fade-in on my site in 1.5 seconds, and after 3 seconds I want it to do a little bounce movement to indicate a scroll movement. I want to repeat the bounce animation every 3rd second but the fade-in only once (when I reload the page).
My code now:
arrow {
position: absolute;
width: 100px;
top: 85vh;
animation: arrowInn 1.5s ease-in forwards, arrowBounce 1s 2s ease-in;
}
#keyframes arrowInn{
from{
opacity: 0;
}
to{
opacity: 100%;
}
}
#keyframes arrowBounce {
0% { bottom: 0px; }
50% { bottom: 10px; }
100% { bottom: 0px; }
}

Your code is already working, you just forgot to add infinite on your second animation:
div {
position: absolute;
width: 100px;
bottom: 10px;
animation: arrowInn 1.5s ease-in forwards, arrowBounce 1s 2s infinite ease-in;
}
#keyframes arrowInn {
from { opacity: 0; }
to { opacity: 100%; }
}
#keyframes arrowBounce {
0% { bottom: 10px; }
50% { bottom: 0; }
100% { bottom: 10px; }
}
<div>⬇️</div>
Also, if you want to make it bounce from the bottom you have to set the bottom property instead of the top on your element. I reversed your arrowBounce animation to make it start from 10px instead of 0, but this part is up to you.

Related

hide a text at the end of the animation

.title2 {
position: absolute;
top: 0;
right: 31%;
animation-name: fadeOutOpacity;
animation-iteration-count: 1;
animation-delay: 2.5s;
animation-timing-function: ease-out;
animation-duration: 1s;
}
#keyframes fadeOutOpacity {
0% {
opacity: 1;
}
90% {
opacity: 0;
}
100% {
display: none;
}
}
Could someone explain to me how I can make it disappear? I thought so it worked but it doesn't work! I wanted to make a text disappear, the effect works but then the text comes back visible when instead I would like to hide it permanently at the end of the animation.
You can use the CSS property animation-fill-mode, and change your Keyframe Animation like so:
.title2 {
position: absolute;
top: 0;
right: 31%;
animation-name: fadeOutOpacity;
animation-iteration-count: 1;
animation-delay: 2.5s;
animation-timing-function: ease-out;
animation-duration: 1s;
animation-fill-mode: forwards;
}
#keyframes fadeOutOpacity {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
If you even toggle the display property from none to block, your transition on other elements will not occur. It's work only with displayed elements. If u want to hide element u can use opacity, height
.title2 {
width: 100px;
height: 50px;
background: red;
position: absolute;
top: 0;
right: 31%;
animation: 1s fadeOutOpacity ease-out;
opacity: 0
}
#keyframes fadeOutOpacity {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<div class="title2"/>

css animation loop needed for <li> elements

I have finally managed to stop the list blurring for a brief second when it hits the breakpoint, but how do I now loop the list? At the moment it ends after the last bullet point.
#media screen and (max-width: 1023px) {
li {
position: absolute;
top: 0;
left: 0;
width:100%;
opacity: 0;
animation: fadeOut 3s ease-out forwards ;
-webkit-animation: fadeOut 3s ease-out forwards;
animation: fadeOut 3s ease-out forwards ;
}
#-webkit-keyframes fadeOut {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes fadeOut {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
li:nth-child(1) {
animation-delay: 0s;
}
li:nth-child(2) {
animation-delay: 3s;
}
li:nth-child(3) {
animation-delay: 6s;
}
li:nth-child(4) {
animation-delay: 9s;
}
}
Ideally I don't want to use JS so would I have to set up a keyframe event each LI's fade in/out? Here is a JSFiddle - https://jsfiddle.net/1gvywmda/1/
I have updated the answer:
https://jsfiddle.net/jwc9rem5/3/
#media screen and (max-width: 1023px) {
.usp-line li:first-child {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.usp-line li:not(:first-child) {
opacity: 0;
transition: opacity .7s;
}
}
give all your li position: relative;
.usp-line li {
position: relative;
width: 100%;
opacity: 0;
transition: opacity .7s;
}
And try removing the line-height property from .usp-line

keyframes only working with codepen.io does not work on brackets.io live preview or jsfiddle.net

Here is all my code... I have two divs that will be moved in opposite directions and exit the screen to redirect to another page. The problem is that the div with id="hat" completes the animation and the div with id="sock" does not move at all. I have tested it in browsers, my IDE live preview. Both did not work.
HTML:
body {
background-color: white;
}
.box {
/* TITLES OF CHOICES */
position: relative;
background-color: gainsboro;
border-radius: 50%;
width: 400px;
height: 400px;
display: inline-block;
margin: 10%;
transition: all 1s;
}
#hat {
background-image: url(hat.jpg);
background-position: center;
}
#sock {
background-image: url(sock.jpeg);
background-position: center;
}
div.box:hover {
/* CHANGE COLOR WHEN MOUSE HOVER */
opacity: 0.5;
}
*/
/* left exit */
#-webkit-keyframes pageExitLeft {
from {
left: 40px;
opacity: 1;
}
to {
left: -440px;
opacity: 0;
}
}
#-moz-keyframes pageExitLeft {
from {
left: 40px;
opacity: 1;
}
to {
left: -440px;
opacity: 0;
}
}
#-o-keyframes pageExitLeft {
from {
left: 40px;
opacity: 1;
}
to {
left: -440px;
opacity: 0;
}
}
#keyframes pageExitLeft {
from {
left: 40px;
opacity: 1;
}
to {
left: -440px;
opacity: 0;
}
}
/* right exit */
#-webkit-keyframes pageExitRight {
from {
right: 40px;
opacity: 1;
}
to {
right: -440px;
opacity: 0;
}
}
#-moz-keyframes pageExitRight {
from {
right: 40px;
opacity: 1;
}
to {
right: -440px;
opacity: 0;
}
}
#-o-keyframes pageExitRight {
from {
right: 40px;
opacity: 1;
}
to {
right: -440px;
opacity: 0;
}
}
#keyframes pageExitRight {
from {
right: 40px;
opacity: 1;
}
to {
right: -440px;
opacity: 0;
}
}
/* ANIMATION SETTING */
#hat {
-webkit-animation: pageExitLeft 2s 1 forwards ease-out;
-moz-animation: pageExitLeft 2s 1 forwards ease-out;
-o-animation: pageExitLeft 2s 1 forwards ease-out;
animation: pageExitLeft 2s 1 forwards ease-out;
}
#sock {
-webkit-animation: pageExitRight 2s 1 forwards ease-out;
-moz-animation: pageExitRight 2s 1 forwards ease-out;
-o-animation: pageExitRight 2s 1 forwards ease-out;
animation: pageExitRight 2s 1 forwards ease-out;
}
<div class="box" id="hat">hat</div>
<div class="box" id="sock">sock</div>
The editor I use is Brackets. I have been trying to find a solution to the transition I am trying to do but couldn't find anything.I have tried to make the animations work and apparently the only place it works is in the website codepen.io I also tried to use it on jsfiddle.net still no difference.

Why does my progress bar animation change state when completed?

I have created a really simple animation which depletes a progress bar using CSS animations.
The problem I am having is once the bar is at 0% (where it should end, it then ends with the bar at 100% again)
.w3-progress-container {
width: 100%;
height: 3px;
position: relative;
background-color: #757575;
}
.w3-progressbar {
background-color: #FBCE07;
height: 100%;
position: absolute;
line-height: inherit;
animation: countdown 10s 1;
-webkit-animation: countdown 10s 1;
animation-timing-function: linear;
}
#-webkit-keyframes countdown {
0% { width:100%; }
100% { width: 0%; }
}
<div class="w3-progress-container">
<div id="myBar" class="w3-progressbar w3-green" style="width:100%"></div>
</div>
Remove the style="width:100%;" and it works.
At a guess, once the animation is complete, It reverts back to its original styling.
The animation-fill-mode property sets the state of the end animation when the animation is not running. Article by David Walsh Article on MDN
.w3-progress-container {
width: 100%;
height: 3px;
position: relative;
background-color: #757575;
}
.w3-progressbar {
background-color: #FBCE07;
height: 100%;
position: absolute;
line-height: inherit;
animation: countdown 10s 1;
-webkit-animation: countdown 10s 1;
animation-timing-function: linear;
animation-fill-mode: forwards;
}
#-webkit-keyframes countdown {
0% { width:100%; }
100% { width: 0%; }
}
<div class="w3-progress-container">
<div id="myBar" class="w3-progressbar w3-green" style="width:100%"></div>
</div>
You have to specify that the animation stay at its final state when it's over:
.w3-progressbar {
...
animation-fill-mode: forwards;
}

CSS animation acting three different ways in Safari, Firefox, and Chrome

Here's what I've got: http://jsfiddle.net/t5p8ypxs/9/
And here is my css:
.wrapper{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
max-width: 960px;
margin: 0 auto;
}
.square{
width:100px;
height:100px;
position: absolute;
background-color:red;
-webkit-animation: imageFrames01 5s ease-out infinite;
-moz-animation: imageFrames01 5s ease-out infinite;
animation: imageFrames01 5s ease-out infinite;
}
#-moz-keyframes imageFrames01 {
0% {
left: 0%;
top: 0%;
}
15.15152% {
left: 0%;
top: 0%;
opacity: 1;
}
30.66667% {
left: 154%;
opacity: 0;
top: -98%;
}
30.67667% {
left: -63%;
opacity: 1;
top: -138%;
}
90.48485% {
left: -63%;
opacity: 1;
top: -138%;
}
}
#-webkit-keyframes imageFrames01 {
/*Same as above in #-moz-keyframes*/
}
#keyframes imageFrames01 {
/*Same as above in #-moz-keyframes*/
}
Safari is the only browser to animate this as I would expect.
Move in from the top-left
Move out to the top-right
Repeat to infinity
In Chrome I get this:
Just appears, with no animation
Move out to the top-right
Repeat to infinity
Firefox is worst with no position animations. Only opacity...
Any ideas. Why is this?
I am using Safari 8, Chrome 42, and Firefox 33
-moz-animation: imageFrames01 66s ease-out infinite;
Try to change the 66s to 5s like the others for Mozilla...