css3 animation delay on right side only - html

I am creating CSS3 animation to make a div move infinity from left to right.
The code is working except for when the div goes to right side, it has a delay of 3 seconds. On the left side, it is working great.
Here is my code:
#najava {
width: 197px;
height: 22px;
border-radius: 2px;
background-color: transparent;
opacity: 0.8;
font-weight: bold;
position: relative;
padding-left: 5px;
padding-right: 5px;
animation: mymove 5s linear 0s infinite alternate-reverse;
font-size: 16px;
font-family: Tahoma, Geneva, sans-serif;
}
#keyframes mymove {
0% {
left: 0px;
}
100% {
left: 200px;
}
}
#keyframes mymove {
0% {
background-color: transparent;
left: 0px;
right: 0px;
}
33% {
background-color: yellow;
left: 250px;
right: 0px;
}
66% {
background-color: blue;
left: 250px;
right: 250px;
}
100% {
background-color: green;
left: 0px;
right: 250px;
}
}
<div id="najava">
<p>text text text text text</p>
</div>

Here is the reason why this is happening.
Your problem lies in the fact that at 66%, nothing is happening. The left remains at 250px which makes it just stay where it's at. The animation is running as it is programmed to do.
To fix this unwanted behavior, you need to remove the 66% line and change it to a simple 0%, 50%, 100% animation.
#keyframes mymove {
0% {background-color:transparent; left:0px; right:0px;}
50% {background-color:yellow; left:250px; right:0px;}
100% {background-color:green; left:0px; right:250px;}
}
This alteration ensures that at 50%, the div is to the right, and at 100%/0%, it's all the way to the left.

Different organization of keyframes, maybe?
#najava {
width: 197px;
height: 22px;
border-radius: 2px;
background-color: transparent;
opacity: 0.8;
font-weight: bold;
position: relative;
padding-left: 5px;
padding-right: 5px;
animation: mymove 3s linear 0s infinite alternate-reverse;
font-size: 16px;
font-family: Tahoma, Geneva, sans-serif;
}
#keyframes mymove {
0% { left: 0px; }
100% { left: 200px; }
}
#keyframes mymove {
0% {background-color:transparent; left:0px; }
25% {background-color:yellow; left:100px; }
50% {background-color:blue; left:200px; }
75% {background-color:red; left:100px; }
100% {background-color:green; left:0px;}
}
<div id="najava">
<p>text text text text text</p>
</div>
p.s. added 5 steps but you can play with the values...

Change your css a bit
CSS:
#keyframes mymove {
0% {background-color:transparent; left:0px}
33% {background-color:yellow; left:250px}
66% {background-color:blue; left:0px; right:250px;}
100% {background-color:green; left:250px;}
}
Full working code:
#najava {
width: 197px;
height: 22px;
border-radius: 2px;
background-color: transparent;
opacity: 0.8;
font-weight: bold;
position: relative;
padding-left: 5px;
padding-right: 5px;
animation: mymove 5s linear 0s infinite alternate-reverse;
font-size: 16px;
font-family: Tahoma, Geneva, sans-serif;
}
#keyframes mymove {
0% {background-color:transparent; left:0px}
33% {background-color:yellow; left:250px}
66% {background-color:blue; left:0px; right:250px;}
100% {background-color:green; left:250px;}
}
<div id="najava">
<p>text text text text text</p>
</div>
Here is the working Demo

Related

Text Animation Glitches on Small Screens

Looking at the following codepen: https://codepen.io/codeams/pen/Ksbcz, I noticed that the animation would glitch if you shrank the window (i.e., the text wraps upon expanding letter-spacing).
h1 letter-spacing animation
body, h1{
margin: 0;
padding: 0;
}
body{
width: 100%;
height: 100%;
background: #30252E;
color: #f0f0f0;
}
h1{
width: 100%;
height: 42px;
position: absolute;
top: calc(50% - 21px);
left: 0;
text-transform: uppercase;
text-align: center;
font: 300 #{42px}/#{1} 'Open sans condensed', sans-serif;
opacity: 0;
animation: in 3s ease-out forwards infinite;
animation-delay: 1s;
}
#keyframes in{
0%{
letter-spacing: -17px;
opacity: 0;
}
30%{
letter-spacing: 4px;
opacity: 1;
}
100%{
letter-spacing: 4px;
opacity: 1;
}
}
How could I do it so that from the screen-size, I would split the words myself and perform the proper animation?
You could place a <span> in between the text and set display:block for the span at the required screen resolution using the media query.
body, h1{
margin: 0;
padding: 0;
}
body{
width: 100%;
height: 100%;
background: #30252E;
color: #f0f0f0;
}
h1{
width: 100%;
height: 42px;
position: absolute;
top: calc(50% - 21px);
left: 0;
text-transform: uppercase;
text-align: center;
font: 300 #{42px}/#{1} 'Open sans condensed', sans-serif;
opacity: 0;
animation: in 3s ease-out forwards infinite;
animation-delay: 1s;
}
#keyframes in{
0%{
letter-spacing: -17px;
opacity: 0;
}
30%{
letter-spacing: 4px;
opacity: 1;
}
100%{
letter-spacing: 4px;
opacity: 1;
}
}
#media only screen and (max-width: 600px) {
span{
display:block; /*Will break the text to next line at screen size 600px*/
}
}
<h1> letter-spacing<span></span> animation</h1>
Letter-spacing doesn't animate at 60fps so it won't appear buttery smooth when animating. The CSS properties that give you smooth animations (60fps) are:
/*postion*/
transform: translate(value, value)
/*scale*/
transform: scale(n)
/*rotation*/
transform: rotate(deg)
/*opacity*/
opacity: 0 though to 1
Any other values will suffer from 'jank' in one form or another. Most of the stuff people try and animate with other properties can be achieved with the 60fps properties though.

CSS3 animation make a stop delay between frames

I'm trying to animate my logo using css, what I want is each logo fade in from top then stop in a certain point, then fade out to bottom, but couldn't make this, is this possible?
.logo {
width: 50px;
height: 50px;
background: whitesmoke;
transform: rotate(45deg);
position: absolute;
border-radius: 5px;
border: 2px solid white;
}
#logo {
width: 500px;
height: 500px;
margin: auto;
margin-top: 100px;
position: relative;
}
#logo-1 {
top: 0px;
animation: loading3 4s linear infinite normal;
}
#logo-2 {
top: -10px;
animation: loading2 3s linear infinite normal;
}
#logo-3 {
top: -20px;
animation: loading1 2s linear infinite normal;
}
#keyframes loading1 {
0% {background: white;opacity: 0;top: -120px;}
50% {background:#f44;opacity: 1;top: -50px;}
65% {background:#f44;opacity: 1;top: -20px;}
75% {background:#f44;opacity: 1;top: -20px;}
100% {background: white;opacity: 0;top: 50px;}
}
#keyframes loading2 {
0% {background: white;opacity: 0;top: -120px;}
50% {background:#f44;opacity: 1;top: -50px;}
65% {background:#f44;opacity: 1;top: -10px;}
75% {background:#f44;opacity: 1;top: -10px;}
100% {background: white;opacity: 0;top: 50px;}
}
#keyframes loading3 {
0% {background: white;opacity: 0;top: -120px;}
50% {background:#f44;opacity: 1;top: -50px;}
65% {background:#f44;opacity: 1;top: 0px;}
75% {background:#f44;opacity: 1;top: 0px;}
100% {background: white;opacity: 0;top: 50px;}
}
<div id="logo">
<div class="logo" id="logo-1"></div>
<div class="logo" id="logo-2"></div>
<div class="logo" id="logo-3"></div>
</div>
Note: logo-3 should come first and stop, then logo-2 come and stop,
then logo-1 come and stop then logo-3 should go first, then logo-2
then logo-1, one by one.
Original logo is:
There is no way to stop a CSS animation in-between and then continue, hence i have used little JavaScript.
What we do is, we divide all three animations into two portions, the first one for all three runs and then the second one. I have divided animations and then activate those animations using classes with JavaScript. This solution is not complex, it's just lengthy.
function animateLogo() {
logo1 = document.getElementById('logo-1');
logo2 = document.getElementById('logo-2');
logo3 = document.getElementById('logo-3');
if(logo1.classList.contains('anim31')) {
logo1.classList.remove('anim31');
logo1.classList.add('anim32');
} else {
logo1.classList.add('anim31');
logo1.classList.remove('anim32');
}
if(logo2.classList.contains('anim21')) {
logo2.classList.remove('anim21');
logo2.classList.add('anim22');
} else {
logo2.classList.add('anim21');
logo2.classList.remove('anim22');
}
if(logo3.classList.contains('anim11')) {
logo3.classList.remove('anim11');
logo3.classList.add('anim12');
} else {
logo3.classList.add('anim11');
logo3.classList.remove('anim12');
}
}
setInterval(animateLogo, 3000); // The time is the amount of milliseconds our longest animation will take i.e 3s
.logo {
width: 50px;
height: 50px;
background: whitesmoke;
transform: rotate(45deg);
position: absolute;
border-radius: 5px;
border: 2px solid white;
}
#logo {
width: 500px;
height: 500px;
margin: auto;
margin-top: 100px;
position: relative;
}
#logo-1 {
top: 0px;
}
#logo-1.anim31 {
animation: loading31 3s linear forwards normal;
}
#logo-1.anim32 {
animation: loading32 1s linear forwards normal;
}
#keyframes loading31 {
0% {
background: white;
opacity: 0;
top: -120px;
}
65% {
background: #f44;
opacity: 1;
top: -50px;
}
75% {
top: -50px;
}
100% {
background: #f44;
opacity: 1;
top: 0px;
}
}
#keyframes loading32 {
0% {
background: #f44;
opacity: 1;
top: 0px;
}
65% {
background: #f44;
opacity: 1;
top: 0px;
}
100% {
background: white;
opacity: 0;
top: 50px;
}
}
#logo-2 {
top: -10px;
}
#logo-2.anim21 {
animation: loading21 2s linear forwards normal;
}
#logo-2.anim22 {
animation: loading22 2s linear forwards normal;
}
#keyframes loading21 {
0% {
background: white;
opacity: 0;
top: -120px;
}
65% {
background: #f44;
opacity: 1;
top: -50px;
}
75% {
top: -50px;
}
100% {
background: #f44;
opacity: 1;
top: -10px;
}
}
#keyframes loading22 {
0% {
background: #f44;
opacity: 1;
top: -10px;
}
65% {
background: #f44;
opacity: 1;
top: -10px;
}
100% {
background: white;
opacity: 0;
top: 50px;
}
}
#logo-3 {
top: -20px;
}
#logo-3.anim11 {
animation: loading11 1s linear forwards normal;
}
#logo-3.anim12 {
animation: loading12 3s linear forwards normal;
}
#keyframes loading11 {
0% {
background: white;
opacity: 0;
top: -120px;
}
65% {
background: #f44;
opacity: 1;
top: -50px;
}
75% {
top: -50px;
}
100% {
background: #f44;
opacity: 1;
top: -20px;
}
}
#keyframes loading12 {
0% {
background: #f44;
opacity: 1;
top: -20px;
}
65% {
background: #f44;
opacity: 1;
top: -20px;
}
100% {
background: white;
opacity: 0;
top: 50px;
}
}
<body>
<div id="logo">
<div class="logo anim31" id="logo-1"></div>
<div class="logo anim21" id="logo-2"></div>
<div class="logo anim11" id="logo-3"></div>
</div>
</body>
I hope this is the expected result. If not, please comment below and i will edit the answer.
P.S: Play around with the timing of animations to make it faster/slower.

Animation Flip HTML5 and CSS3 Doubts

I need do the next animation of text:
People dissapears like a flip effect David Walsh Flip Card Effect, and the effect faces every 2 seconds and it will be repeating, contents the text: "Robots", "Animals", "Things" for example, with the flip animation.
Any idea?
One example of flip cards is the next: Stackoverflow How to flip multiple divs using CSS?
#import url('https://fonts.googleapis.com/css?family=Roboto:300');
.divi {
line-height: normal;
color: black;
text-shadow: 0 0 0.2em #87F, 0 0 0.2em #87F, 0 0 0.2em #87F;
}
.div1 { /* For increasing performance ID/Class should've been used. For a small demo it's okaish for now */
animation: showup 7s forwards;
font-family:'Roboto';
font-weight:300;
font-size:28px;
overflow:hidden;
display:inline-block;
white-space:nowrap;
}
.div2 {
font-family: 'Roboto';
font-weight: 300;
font-size: 28px;
overflow: hidden;
width: 0px;
animation: reveal 7s forwards;
animation-iteration-count: 1;
display: inline-block;
white-space: nowrap;
}
.div2 span {
font-family: 'Roboto';
font-weight: 300;
font-size: 28px;
overflow: hidden;
margin-left: -355px;
animation: slidein 7s forwards;
}
#keyframes showup {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 1;
}
}
#keyframes slidein {
0% {
margin-left: -800px;
}
20% {
margin-left: -800px;
}
35% {
margin-left: 0px;
}
100% {
margin-left: 0px;
}
}
#keyframes reveal {
0% {
opacity: 0;
width: 0px;
}
20% {
opacity: 1;
width: 0px;
}
30% {
width: auto;
}
80% {
opacity: 1;
}
100% {
opacity: 1;
width: auto;
}
}
<div class="divi" align="center">
<div class="div1">Hello</div>
<div class="div2">
<span>People</span>
</div>
<div class="div3">
<span>Robots</span>
</div>
<div class="div4">
<span>Animals</span>
</div>
<div class="div5">
<span>Things</span>
</div>
</div>

Display Div after CSS Animation Ends

I have a Windows 10 Simulator script made mostly out of CSS Animations. I successfully created the color gradient but now I have no clue on how to do the next step.
Main HTML and CSS
<html>
<head>
<title>Windows 10 Simulator</title>
<link href="https://fonts.googleapis.com/
css?family=Noto+Sans|Open+Sans|PT+Sans|
Raleway|Source+Sans+Pro" rel="stylesheet">
</head>
<body>
<style onload>
html, body{
margin: 0;
padding: 0;
background-color: #000;
}
.wrapper {
height: 100%;
width: 100%;
left:0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
background: linear-gradient(124deg, #000000,
#000000, #0095f0 ,#0095f0, #0095F0, #ff0000,
#ff0000, #0095f0);
background-size: 1800% 1800%;
animation-iteration-count: 0;
animation-fill-mode: forwards;
animation: rainbow 30s ease 1;
}
#keyframes rainbow {
0% {background-position: 0% 0%}
10%{background-position: 100%% 15%}
20%{background-position: 100% 30%}
30%{background-position: 100% 45%}
40%{background-position: 100% 60%}
50%{background-position: 100% 85%}
60%{background-position: 100% 90%}
70%{background-position: 100% 100%}
80%{background-position: 100% 90%}
90%{background-position: 100% 85%}
80%{background-position: 100% 45%}
100%{background-position:100% 15%}
}
span {
margin-top: 250px;
color: #fff;
font-size: 30px;
font-family: 'Raleway', sans-serif;
animation-name: flickerAnimation;
animation-duration: 5s;
animation-iteration-count: 1;
position: absolute;
opacity: 0;
left: 0;
right: 0;
text-align: center;
}
#message{
font-size: 10px;
color: #fff;
animation-name: alertFade;
animation-duration: 4s;
opacity: 0;
animation-iteration-count: 1000;
margin-top: 620px;
}
span:nth-child(1) {
animation-delay: 1s;
animation-duration: 5s;
}
span:nth-child(2) {
animation-delay: 7s;
animation-duration: 7s;
}
span:nth-child(3) {
animation-delay: 15s;
}
span:nth-child(4) {
animation-delay: 22s;
}
#keyframes flickerAnimation{
0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: .0;}
}
#keyframes alertFade{
0% {opacity: .25}
50% {opacity: .75}
100% {opacity: .25}
}
</style>
<div class="wrapper">
<span>Hello! </span>
<span>Please Wait While We Setup</span>
<span>This Will Only Take a Few Seconds</span>
<span>Just a second...</span>
<div style="text-align: center;">
<p id="message" align="center">Please Do Not Turn
Off Your Device.</p>
</div>
</div>
</body>
</html>
I am trying to get the following block of code to appear once the previous CSS Animation has finished :
#login{
margin-left: 25px;
margin-top: 80px;
text-align: center;
background-color: #000;
width: 350px;
height: 425px;
}
#icon{
margin-top: 50px;
width: 150px;
border-radius: 100px;
}
#other{
color: #fff;
font-size: 25px;
}
input[type=password] {
width: 70%;
height: 40px;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 1px solid #555;
   outline: none;
position: static;
}
input[type="submit"]
/*button*/{
margin-left: -41px;
height: 35.5px;
width: 32.5px;
}
#go{
background-color: gray;
color: gray;
border: none;
}
#hint{
color: #fff;
font-size: 8px;
}
</style>
<div style="text-align: center;">
<form action="tbd.htm" id="login">
<img src="http://chittagongit.com/
/images/windows-user-icon/windows-user-icon-14.jpg"
id="icon">
<p id="other" style="text-align: center;">Other User</p>
<p id="hint">Hint: Type Anything.</p>
<input type="password" name="password"
placeholder="Password"/>
<input type="submit" id="go">
</form>
</div>
How exactly can I execute this plan?
I'd just chain it to the sequence time of the actual animation since it's a fixed value anyway like so (you'll need to click the full-screen option to see example);
Oh, and PS -- I would highly recommend working to improve your code formatting habits and adhering to a cleaner DOM structure, but either way hope this helps. Cheers!
html, body{
margin: 0;
padding: 0;
background-color: #000;
}
.wrapper {
position: fixed;
left:0;
right: 0;
top: 0;
bottom: 0;
background: linear-gradient(124deg, #000000,
#000000, #0095f0 ,#0095f0, #0095F0, #ff0000,
#ff0000, #0095f0);
background-size: 1800% 1800%;
animation-iteration-count: 0;
animation-fill-mode: forwards;
animation: rainbow 30s ease 1;
}
#keyframes rainbow {
0% {background-position: 0% 0%}
10%{background-position: 100%% 15%}
20%{background-position: 100% 30%}
30%{background-position: 100% 45%}
40%{background-position: 100% 60%}
50%{background-position: 100% 85%}
60%{background-position: 100% 90%}
70%{background-position: 100% 100%}
80%{background-position: 100% 90%}
90%{background-position: 100% 85%}
80%{background-position: 100% 45%}
100%{background-position:100% 15%}
}
#message{
font-size: 10px;
color: #fff;
animation-name: alertFade;
animation-duration: 4s;
text-align: center;
opacity: 0;
animation-iteration-count: 1000;
margin-top: 620px;
}
span {
margin-top: 250px;
color: #fff;
font-size: 30px;
font-family: 'Raleway', sans-serif;
animation-name: flickerAnimation;
animation-duration: 5s;
animation-iteration-count: 1;
position: absolute;
opacity: 0;
left: 0;
right: 0;
text-align: center;
}
span:nth-child(1) {
animation-delay: 1s;
animation-duration: 5s;
}
span:nth-child(2) {
animation-delay: 7s;
animation-duration: 7s;
}
span:nth-child(3) {
animation-delay: 15s;
}
span:nth-child(4) {
animation-delay: 22s;
}
#keyframes flickerAnimation{
0% {opacity: 0;}
50% {opacity: 1;}
100% {opacity: .0;}
}
#keyframes alertFade{
0% {opacity: .25}
50% {opacity: .75}
100% {opacity: .25}
}
#keyframes finale {
from {opacity: 0}
to {opacity: 1}
}
#login {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
border: red 1px dashed;
opacity: 0;
animation: finale 1s ease forwards;
animation-delay: 30s;
}
<div class="wrapper">
<span>Hello! </span>
<span>Please Wait While We Setup</span>
<span>This Will Only Take a Few Seconds</span>
<span>Just a second...</span>
<p id="message">
Please Do Not Turn Off Your Device.
</p>
<form action="tbd.htm" id="login">
<img src="http://chittagongit.com/
/images/windows-user-icon/windows-user-icon-14.jpg"
id="icon">
<p id="other" style="text-align: center;">Other User</p>
<p id="hint">Hint: Type Anything.</p>
<input type="password"
name="password"
placeholder="Password"/>
<input type="submit"
id="go">
</form>
</div>

Keep rotating CSS animation level

I have this:
div {
position: relative;
width: 20px;
height: 100px;
border-radius: 10px;
background: green;
margin: 0 auto;
transform-origin: 10px 10px;
animation: rotate 1s ease-in-out infinite alternate;
}
#keyframes rotate {
from {transform: rotate(-30deg);}
to {transform: rotate(30deg);}
}
hr {
position: relative;
top: -10px;
}
<div></div>
<hr>
But I want something like this:
div {
position: relative;
width: 20px;
height: 100px;
border-radius: 10px;
background: green;
margin: 0 auto;
transform-origin: 10px 10px;
animation: rotate 1s ease-in-out infinite alternate, translate 0.5s ease-in-out infinite alternate;
}
#keyframes rotate {
from {transform: rotate(-30deg);}
to {transform: rotate(30deg);}
}
#keyframes translate {
from {top: 10px;}
to {top: 0px;}
}
hr {
position: relative;
top: -10px;
}
<div></div>
<hr>
EDIT: I probably didn't explain this well enough. What I meant is, is there a way to keep the bottom of the div touching the line witout using any sort of animation to move it up and down? I want it to be dynamic, so that if I change the value of the rotation, I won't have to calculate and change the value of the translation.
EDIT2: Simply put: I just want the div to do what the second example is doing without needing a specific value for the vertical movement.
You should play with values to get it perfect but this is the idea:
div {
position: relative;
width: 20px;
height: 100px;
border-radius: 10px;
background: green;
margin: 0 auto;
transform-origin: 10px 10px;
animation: rotate 1s ease-in-out infinite alternate;
}
#keyframes rotate {
0% {transform: rotate(-30deg); top: 10px;}
50% {top: 0px;}
100% {transform: rotate(30deg); top: 10px;}
}
hr {
position: relative;
top: -10px;
}
<div></div>
<hr>
I'm not sure that this is what do you expect, but I will give it a try.
* {
margin: 0;
padding: 0;
}
div {
width: 20px;
height: 100px;
border-radius: 10px;
background: green;
margin: 0 auto;
transform-origin: 10px 10px;
animation: rotate 1s ease-in-out infinite alternate, stretch 1s ease-in-out infinite;
}
hr {
position: absolute;
top: 99px;
width: 99%;
}
#keyframes rotate {
from {
transform: rotate(-30deg);
}
to {
transform: rotate(30deg);
}
}
#keyframes stretch {
0% {
height: 112px;
}
50% {
height: 100px;
}
100% {
height: 112px;
}
}
<div></div>
<hr>