How to play css with delay on each iteration? - html

I have a couple of animations (bars) I want to delay execution so as to alternate between them. First 1, when it finishes the other and so on... but I have been able only to delay the first iteration of the animation. After that it triggers with no delay!
#-webkit-keyframes width {
0% {
width: 0px;
}
100% {
width: 600px;
}
}
div {
width: 0px;
height: 40px;
padding-left: 0px;
margin: 10px 0;
color: white;
font: 18px Georgia;
line-height: 40px;
vertical-align: middle;
background: #05f;
-webkit-animation: width 15s infinite;
-moz-animation: width 15s infinite;
-o-animation: width 15s infinite;
}
#div1 {
background-color: #008000;
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 6s;
-webkit-animation-delay: 3s;
-webkit-animation-iteration-count: 8;
}
#div2 {
background-color:#ff0000;
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 4s;
-webkit-animation-delay: 9s;
-webkit-animation-iteration-count: 8;
}
#div1 {
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 6s;
-webkit-animation-delay: 3s;
-webkit-animation-iteration-count: 8;
}
#div2 {
-webkit-animation-timing-function: linear;
-webkit-animation-duration: 4s;
-webkit-animation-delay: 9s;
-webkit-animation-iteration-count: 8;
}
<div id="div1">1st line</div>
<div id="div2">2nd line</div>
<div id="p_bar" class="p_bar"></div>

To run three animations consecutively, I would suggest to create one animation that will run one third of the total time length and then, you put three different -webkit-animation-delay for every of them. Please see below the example:
#-webkit-keyframes width {
0% {
width: 0px;
}
33.33% {
width: 600px;
}
100% {
width: 600px;
}
}
div {
width: 0px;
height: 40px;
padding-left: 0px;
margin: 10px 0;
color: white;
font: 18px Georgia;
line-height: 40px;
vertical-align: middle;
-webkit-animation: width 15s 8;
-moz-animation: width 15s 8;
-o-animation: width 15s 8;
-webkit-animation-timing-function: linear;
}
#div1 {
background-color: #008000;
}
#div2 {
background-color:#ff0000;
-webkit-animation-delay: 5s;
}
#div3 {
background-color:#0055ff;
-webkit-animation-delay: 10s;
}
<div id="div1">1st line</div>
<div id="div2">2nd line</div>
<div id="div3">3rd line</div>

Related

Add animation to final square in animation

I have this animation in HTML/CSS. The final square in the animation is in green, i'm trying to make it so that each time the green square show up prior to the last time the animation looped. Because in its current state it always shows up at the last square!
HTML:
<div class="loader">
<div class="square" ></div>
<div class="square"></div>
<div class="square last"></div>
<div class="square clear"></div>
<div class="square"></div>
<div class="square last"></div>
<div class="square clear"></div>
<div class="square "></div>
<div class="square last"></div>
</div>
CSS
#-webkit-keyframes enter {
0% {
opacity: 0;
top: -10px;
}
5% {
opacity: 1;
top: 0px;
}
50.9% {
opacity: 1;
top: 0px;
}
55.9% {
opacity: 0;
top: 10px;
}
}
#keyframes enter {
0% {
opacity: 0;
top: -10px;
}
5% {
opacity: 1;
top: 0px;
}
50.9% {
opacity: 1;
top: 0px;
}
55.9% {
opacity: 0;
top: 10px;
}
}
#-moz-keyframes enter {
0% {
opacity: 0;
top: -10px;
}
5% {
opacity: 1;
top: 0px;
}
50.9% {
opacity: 1;
top: 0px;
}
55.9% {
opacity: 0;
top: 10px;
}
}
body {
background: #1fbeca;
}
* {
margin: 0;
}
.loader {
position: absolute;
left: 50%;
top: 50%;
margin-left: -27.5px;
margin-top: -27.5px;
}
.square {
background: white;
width: 15px;
height: 15px;
float: left;
top: -10px;
margin-right: 5px;
margin-top: 5px;
position: relative;
opacity: 0;
-webkit-animation: enter 6s infinite;
animation: enter 6s infinite;
}
.enter {
top: 0px;
opacity: 1;
}
.square:nth-child(1) {
-webkit-animation-delay: 1.8s;
-moz-animation-delay: 1.8s;
animation-delay: 1.8s;
}
.square:nth-child(2) {
-webkit-animation-delay: 2.1s;
-moz-animation-delay: 2.1s;
animation-delay: 2.1s;
}
.square:nth-child(3) {
-webkit-animation-delay: 2.4s;
-moz-animation-delay: 2.4s;
animation-delay: 2.4s;
background: #fdc96f;
}
.square:nth-child(4) {
-webkit-animation-delay: 0.9s;
-moz-animation-delay: 0.9s;
animation-delay: 0.9s;
}
.square:nth-child(5) {
-webkit-animation-delay: 1.2s;
-moz-animation-delay: 1.2s;
animation-delay: 1.2s;
}
.square:nth-child(6) {
-webkit-animation-delay: 1.5s;
-moz-animation-delay: 1.5s;
animation-delay: 1.5s;
}
.square:nth-child(8) {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.square:nth-child(9) {
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
animation-delay: 0.6s;
}
.clear {
clear: both;
}
.last {
margin-right: 0;
}
Here's a link: https://codepen.io/dghez/pen/Czuqn
To have the colored square shift position every time the 'enter' animation is run, create a new animation that is 9 times the length of the 'enter' animation.
The reason for this length is that each of the 9 squares needs to be animated for one full run of the 'enter' animation.
9 squares x 6s = 54s.
For 1/9 of this animation (roughly 11%), we change the square's color.
#keyframes squarecolor {
0%, 11.1% {
background-color: #fdc96f;
}
11.2%, 100% {
background-color: white;
}
}
Then, apply this animation to every square, just like the 'enter' animation. Here though, each square should be progressively delayed in increments of 6s.
Here's a link to an updated version of your Codepen.
You can achieve the affect by using a 2nd animation that changes a square at a time to yellow for one entire loop of the animation.
The 2nd animation loops after the 1st animation has run for all 9 squares (6s * 9 = 54s), and each square is delayed to some interval of 6s to line up with the corresponding loop where it should be yellow.
#-webkit-keyframes enter {
0% {
opacity: 0;
top: -10px;
}
5% {
opacity: 1;
top: 0px;
}
50.9% {
opacity: 1;
top: 0px;
}
55.9% {
opacity: 0;
top: 10px;
}
}
#keyframes enter {
0% {
opacity: 0;
top: -10px;
}
5% {
opacity: 1;
top: 0px;
}
50.9% {
opacity: 1;
top: 0px;
}
55.9% {
opacity: 0;
top: 10px;
}
}
#-webkit-keyframes change {
0% {
background: #fdc96f;
}
11.11% { /* one 6s frame in a 54s animation (6/54 = .1111) */
background: #fdc96f;
}
11.12% {
background: white;
}
100% {
background: white;
}
}
#keyframes change {
0% {
background: #fdc96f;
}
11.11% {
background: #fdc96f;
}
11.12% {
background: white;
}
100% {
background: white;
}
}
body {
background: #1fbeca;
}
* {
margin: 0;
}
.loader {
position: absolute;
left: 50%;
top: 50%;
margin-left: -27.5px;
margin-top: -27.5px;
}
.square {
background: white;
width: 15px;
height: 15px;
float: left;
top: -10px;
margin-right: 5px;
margin-top: 5px;
position: relative;
opacity: 0;
}
.enter {
top: 0px;
opacity: 1;
}
.square:nth-child(1) {
-webkit-animation: enter 6s 1.8s infinite, change 54s 12s infinite;
animation: enter 6s 1.8s infinite, change 54s 12s infinite;
}
.square:nth-child(2) {
-webkit-animation: enter 6s 2.1s infinite, change 54s 6s infinite;
animation: enter 6s 2.1s infinite, change 54s 6s infinite;
}
.square:nth-child(3) {
-webkit-animation: enter 6s 2.4s infinite, change 54s infinite;
animation: enter 6s 2.4s infinite, change 54s infinite;
}
.square:nth-child(4) {
-webkit-animation: enter 6s 0.9s infinite, change 54s 30s infinite;
animation: enter 6s 0.9s infinite, change 54s 30s infinite;
}
.square:nth-child(5) {
-webkit-animation: enter 6s 1.2s infinite, change 54s 24s infinite;
animation: enter 6s 1.2s infinite, change 54s 24s infinite;
}
.square:nth-child(6) {
-webkit-animation: enter 6s 1.5s infinite, change 54s 18s infinite;
animation: enter 6s 1.5s infinite, change 54s 18s infinite;
}
.square:nth-child(7) {
-webkit-animation: enter 6s infinite, change 54s 48s infinite;
animation: enter 6s infinite, change 54s 48s infinite;
}
.square:nth-child(8) {
-webkit-animation: enter 6s 0.3s infinite, change 54s 42s infinite;
animation: enter 6s 0.3s infinite, change 54s 42s infinite;
}
.square:nth-child(9) {
-webkit-animation: enter 6s 0.6s infinite, change 54s 36s infinite;
animation: enter 6s 0.6s infinite, change 54s 36s infinite;
}
.clear {
clear: both;
}
.last {
margin-right: 0;
}
<div class="loader">
<div class="square"></div>
<div class="square"></div>
<div class="square last"></div>
<div class="square clear"></div>
<div class="square"></div>
<div class="square last"></div>
<div class="square clear"></div>
<div class="square "></div>
<div class="square last"></div>
</div>
Pen: https://codepen.io/straker/pen/mqdzMw

HTML, and CSS for Breaking news ticker

I am struggling to get the word "Breaking" to be centered in the Box it is in. I am also struggling getting the scrolling to be continuous, right now there is too much of a delay. I would also like the "Breaking", and the "TEST" headline to stand out, and be more bold. Right now the coding is done, and it works. Just a few minor tweaks. Also is it possible to make whatever I type into "breaking"and test" be a link as well?
.breaking-news-headline {
display: block;
position: absolute;
font-family: arial;
font-size: 15px;
margin-top: -22px;
color: white;
margin-left: 150px;
}
.breaking-news-title {
background-color: #FFFF00;
display: block;
height: 20px;
width: 120px;
font-family: arial;
font-size: 15px;
position: absolute;
top: 0px;
margin-top: auto;
margin-left: auto;
padding-top: 10px;
padding-left: 10px;
z-index: 3;
&:before {
content: "";
position: absolute;
display: block;
width: 0px;
height: 0px;
top: 10;
left: -12px;
border-left: 12px solid transparent;
border-right: 0px solid transparent;
border-bottom: 30px solid #FFEA00;
}
&:after {
content: "";
position: absolute;
display: block;
width: 10px;
height: 0px;
right: -12px;
top: 0;
border-right: 12px solid transparent;
border-left: 0px solid transparent;
border-top: 30px solid #FFEA00;
}
}
#breaking-news-colour {
height: 30px;
width: 2394px;
background-color: #FF0000;
}
#breaking-news-container {
height: 30px;
width: 800px;
overflow: hidden;
position: absolute;
&:before {
content: "";
width: 30px;
height: 30px;
background-color: #3399FF;
position: absolute;
z-index: 2;
}
}
.animated {
-webkit-animation-duration: 0.2s;
-webkit-animation-fill-mode: both;
-moz-animation-duration: 0.2s;
-moz-animation-fill-mode: both;
-webkit-animation-iteration-count: 1;
-moz-animation-iteration-count: 1;
}
.delay-animated {
-webkit-animation-duration: 0.4s;
-webkit-animation-fill-mode: both;
-moz-animation-duration: 0.4s;
-moz-animation-fill-mode: both;
-webkit-animation-iteration-count: 1;
-moz-animation-iteration-count: 1;
-webkit-animation-delay: 0.3s;
animation-delay: 0.3s;
}
.scroll-animated {
-webkit-animation-duration: 3s;
-webkit-animation-fill-mode: both;
-moz-animation-duration: 3s;
-moz-animation-fill-mode: both;
-webkit-animation-iteration-count: 1;
-moz-animation-iteration-count: 1;
-webkit-animation-delay: 0.5s;
animation-delay: 0.5s;
}
.delay-animated2 {
-webkit-animation-duration: 0.4s;
-webkit-animation-fill-mode: both;
-moz-animation-duration: 0.4s;
-moz-animation-fill-mode: both;
-webkit-animation-iteration-count: 1;
-moz-animation-iteration-count: 1;
-webkit-animation-delay: 0.5s;
animation-delay: 0.5s;
}
.delay-animated3 {
-webkit-animation-duration: 5s;
-webkit-animation-fill-mode: both;
-moz-animation-duration: 5s;
-moz-animation-fill-mode: both;
-webkit-animation-iteration-count: 1;
-moz-animation-iteration-count: 1;
-webkit-animation-delay: 0.5s;
animation-delay: 3s;
}
.fadein {
-webkit-animation-name: fadein;
-moz-animation-name: fadein;
-o-animation-name: fadein;
animation-name: fadein;
}
#-webkit-keyframes fadein {
from {
margin-left: 1000px
}
to {}
}
#-moz-keyframes fadein {
from {
margin-left: 1000px
}
to {}
}
.slidein {
-webkit-animation-name: slidein;
-moz-animation-name: slidein;
-o-animation-name: slidein;
animation-name: slidein;
}
#keyframes marquee {
0% {
left: 0;
}
20% {
left: 0;
}
100% {
left: -100%;
}
}
.marquee {
animation: marquee 3s linear infinite;
-webkit-animation-duration: 10s;
-moz-animation-duration: 10a;
-webkit-animation-delay: 0.5s;
animation-delay: 3s;
}
#-webkit-keyframes slidein {
from {
margin-left: 800px
}
to {
margin-top: 0px
}
}
#-moz-keyframes slidein {
from {
margin-left: 800px
}
to {
margin-top: 0px
}
}
.slideup {
-webkit-animation-name: slideup;
-moz-animation-name: slideup;
-o-animation-name: slideup;
animation-name: slideup;
}
#-webkit-keyframes slideup {
from {
margin-top: 30px
}
to {
margin-top: 0;
}
}
#-moz-keyframes slideup {
from {
margin-top: 30px
}
to {
margin-top: 0;
}
}
<div id="breaking-news-container">
<div id="breaking-news-colour" class="slideup animated">
</div>
<span class="breaking-news-title delay-animated slidein">
BREAKING
</span>
<a class="breaking-news-headline delay-animated2 fadein marquee">
TEST
</a>
</div>
I am struggling to get the word "Breaking" to be centered in the Box it is in
.breaking-news-title {
text-align: center;
font-weight: bold;
padding-top: 7px;
height: 30px;
}
delete → padding-left: 0px;
I would also like the "Breaking", and the "TEST" headline to stand
out, and be more bold.
just add font-weight: bold;
Also is it possible to make whatever I type into "breaking"and test"
be a link as well? Thanks!
yes, replace your span to <a> tag and your "TEST" is already <a> tag
and by the way according to caniuse.com <marquee> tag is deprecated so you should not use it
http://caniuse.com/#search=marquee
but here is the edit I made
https://jsfiddle.net/gs8p0zc3/
use this css3 animation instead of marquee
EDIT made similar design of your code
https://jsfiddle.net/sfjjvpk5/1/

CSS3 Animation-fill-mode property

I'm creating an effect where text slides into the window and stays there after the animation ends. I've been able to get the animation to work on 1 piece of the text, but for some reason the 2nd piece is not working.
Please see my fiddle https://jsfiddle.net/9fpryou8/
Thanks in advance.
figure h2.world {
position: absolute;
top: 20%;
left: 61%;
background-color: transparent;
font-size: 7em;
color: white;
font-family: Paytone One, Verdana, sans-serif;
transform: translateX(300%);
text-shadow: 0px 0px 50px black;
-moz-animation-name: slideWorld;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
-moz-animation-duration: 0.4s;
-moz-animation-delay: 1.4s;
-moz-animation-fill-mode: forwards;
-webkit-animation-name: slideWorld;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-webkit-animation-duration: 0.4s;
-webkit-animation-delay: 1.4s;
-webkit-animation-fill-mode: forwards;
animation-name: slideWorld;
animation-iteration-count: 1.4;
animation-timing-function: ease-in;
animation-duration: 0.4s;
animation-delay: 1.4s;
animation-fill-mode: forwards;
}
In .world, replace
animation-iteration-count: 1.4;
with
animation-iteration-count: 1;
figure {
height: 98vh;
background-color: grey;
}
figure h2.hello {
position: absolute;
top: 20%;
left: 39%;
font-size: 1em;
background-color: transparent;
color: white;
font-family: Paytone One, Verdana, sans-serif;
transform: translateX(-400%);
text-shadow: 0px 0px 50px black;
-moz-animation-name: slideHello;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
-moz-animation-duration: 0.4s;
-moz-animation-delay: 1s;
-moz-animation-fill-mode: forwards;
-webkit-animation-name: slideHello;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-webkit-animation-duration: 0.4s;
-webkit-animation-delay: 1s;
-webkit-animation-fill-mode: forwards;
animation-name: slideHello;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 0.4s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
figure h2.world {
position: absolute;
top: 20%;
left: 61%;
background-color: transparent;
font-size: 1em;
color: white;
font-family: Paytone One, Verdana, sans-serif;
transform: translateX(300%);
text-shadow: 0px 0px 50px black;
-moz-animation-name: slideWorld;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
-moz-animation-duration: 0.4s;
-moz-animation-delay: 1.4s;
-moz-animation-fill-mode: forwards;
-webkit-animation-name: slideWorld;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-webkit-animation-duration: 0.4s;
-webkit-animation-delay: 1.4s;
-webkit-animation-fill-mode: forwards;
animation-name: slideWorld;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 0.4s;
animation-delay: 1.4s;
animation-fill-mode: forwards;
}
/**** Display Hello on Load ****/
#-moz-keyframes slideHello {
to {
-moz-transform: translateX(-39%);
}
}
#-webkit-keyframes slideHello {
to {
-webkit-transform: translateX(-39%);
}
}
#keyframes slideHello {
to {
transform: translateX(-39%);
}
}
/**** Display World on Load ****/
#-moz-keyframes slideWorld {
to {
-moz-transform: translateX(-61%);
}
}
#-webkit-keyframes slideWorld {
to {
-webkit-transform: translateX(-61%);
}
}
#keyframes slideWorld {
to {
transform: translateX(-61%);
}
}
<figure>
<h2 class="hello">Hello</h2>
<h2 class="world">World</h2>
</figure
Or simple delete it: the initial value of animation-iteration-count is 1.
you have a typing mistake
change animation-iteration-count: 1.4; to animation-iteration-count: 1;
then it should work

Can I apply animations to margins?

I'm trying to animate in CSS3 margins, which this site seems to say you can, but I can't get working.
I actually have 3 animations. 1 for a simple initial fadeIn on initial load, then the 2 others for the margin animation on click. I've also just tried margin instead of the top and bottom but still no sign of it working.
Click on a section to see animation toggle.
$(".section").click(function() {
$(this).toggleClass("open");
});
body{
background: #f1f1f1;
}
.section{
display: block;
background: #fff;
border-bottom: 1px solid #f1f1f1;
animation: fadeIn .5s ease, margin-top .5s ease, margin-bottom .5s ease;
}
.section.open {
margin: 20px 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div class="wrapper">
<div class="section">Some content</div>
<div class="section">Some content</div>
<div class="section">Some content</div>
<div class="section">Some content</div>
<div class="section">Some content</div>
<div class="section">Some content</div>
<div class="section">Some content</div>
</div>
Here is a JSFiddle: http://jsfiddle.net/ybh0thp9/3/
You don't need keyframes for this: http://jsfiddle.net/BramVanroy/ybh0thp9/7/
transition: margin 700ms;
You need to add the transition property to the base element that you wish to animate.
You also mentioned that you wanted opacity change, but I don't see how that's possible considering you only have a single element without children. I mean: you can't click on the element if it's hidden.
What you can do, though, is add opacity to the whole thing: http://jsfiddle.net/BramVanroy/ybh0thp9/9/
Or even prettier, with a transformation:
http://jsfiddle.net/BramVanroy/ybh0thp9/10/
.section {
margin: 0;
opacity: 0.7;
transform: scale(0.85);
transition: all 700ms;
}
.section.open {
margin: 20px 0;
opacity: 1;
transform: scale(1);
}
Per comment, you want to fade in the elements on page load. We can do that by adding a class init.
http://jsfiddle.net/BramVanroy/ybh0thp9/12/
$(".section").addClass("init"); // JS
.section.init {opacity: 1;} // CSS
With keyframes: http://jsfiddle.net/BramVanroy/ybh0thp9/14/
#-webkit-keyframes fadeIn { from {opacity: 0; } to { opacity: 1; } }
#-moz-keyframes fadeIn { from {opacity: 0; } to { opacity: 1; } }
#keyframes fadeIn { from {opacity: 0; } to { opacity: 1; } }
-webkit-animation: fadeIn 1.5s ease;
-moz-animation: fadeIn 1.5s ease;
animation: fadeIn 1.5s ease;
Tip for using transitions if it still isn't working...
Make sure you're not setting two separate transitions for different properties like this:
transition: margin 1000ms ease-in-out;
transition: box-shadow 1000ms ease-in-out;
It's obvious what's happening when looking in your browser's debugging tools:
The box-shadow will animate as intended, but margin isn't considered due to normal css rule handling.
The correct way is to combine the rules:
transition: margin 1000ms ease-in-out, box-shadow 1000ms ease-in-out;
To create animations witch CSS3 you need to:
Create a class with animation attribute; to work in some browsers you need to put prefixes: -webkit-, -o-, -moz-.
Create animation keyframes
see the example:
.animate{
animation: myAnimation 10s;
animation-direction: alternate;
animation-play-state: running;
animation-iteration-count: infinite;
animation-delay: 0;
animation-timing-function: 1;
animation-direction: alternate;
-webkit-animation: myAnimation 10s;
-webkit-animation-direction: alternate;
-webkit-animation-play-state: running;
-webkit-animation-iteration-count: infinite;
-webkit-animation-delay: 0;
-webkit-animation-timing-function: 1;
-webkit-animation-direction: alternate;
-moz-animation: myAnimation 10s;
-moz-animation-direction: alternate;
-moz-animation-play-state: running;
-moz-animation-iteration-count: infinite;
-moz-animation-delay: 0;
-moz-animation-timing-function: 1;
-moz-animation-direction: alternate;
-o-animation: myAnimation 10s;
-o-animation-direction: alternate;
-o-animation-play-state: running;
-o-animation-iteration-count: infinite;
-o-animation-delay: 0;
-o-animation-timing-function: 1;
-o-animation-direction: alternate;
}
#keyframes myAnimation {
0% { margin-top: 0; margin-left: 50px}
25% { margin-top: 100px; margin-left: 50px }
50% { margin-top: 0; margin-left: 50px }
75% { margin-top: 100px; margin-left: 50px }
100% { margin-top: 0; margin-left: 50px }
}
#-webkit-keyframes myAnimation {
0% { margin-top: 0; margin-left: 100px}
25% { margin-top: 100px; margin-left: 100px }
50% { margin-top: 0; margin-left: 100px }
75% { margin-top: 100px; margin-left: 100px }
100% { margin-top: 0; margin-left: 100px }
}
#-moz-keyframes myAnimation {
0% { margin-top: 0; margin-left: 100px}
25% { margin-top: 100px; margin-left: 100px }
50% { margin-top: 0; margin-left: 100px }
75% { margin-top: 100px; margin-left: 100px }
100% { margin-top: 0; margin-left: 100px }
}
#-o-keyframes myAnimation {
0% { margin-top: 0; margin-left: 100px}
25% { margin-top: 100px; margin-left: 100px }
50% { margin-top: 0; margin-left: 100px }
75% { margin-top: 100px; margin-left: 100px }
100% { margin-top: 0; margin-left: 100px }
}

How to set animation in css?

How to put my text moving from beginig to the end of the div constantly. I did something like this http://jsfiddle.net/swh2jqrg/ on my web page, but my message is going out in new line. I want that my text goes in a loop(circle). how to do that? my css looks like this:
.message1{
width: 1240px;
height: 94px;
font-size: 70px;
text-align:center;
color: white;
animation-duration: 10s;
animation-name: slidein;
animation-iteration-count: infinite;
animation-delay: forwards;
animation-direction: normal;
}
#keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
Why this isn't working in Crome? sorry for the english and thanks for the answer.
You need to add vendor prefixes for chrome, -webkit-:
.content1{
width: 1280px;
height: 322px;
}
.message{
width: 1240px;
height: 94px;
background-color:#5292a5;
margin: 25px 20px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.message1{
width: 1240px;
height: 94px;
font-size: 70px;
text-align:center;
color: white;
-webkit-animation-duration: 10s;
-webkit-animation-name: slidein;
-webkit-animation-iteration-count: infinite;
-webkit-animation-delay: forwards;
-webkit-animation-direction: normal;
animation-duration: 10s;
animation-name: slidein;
animation-iteration-count: infinite;
animation-delay: forwards;
animation-direction: normal;
}
#-webkit-keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
#keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
Demo in a fiddle: http://jsfiddle.net/swh2jqrg/1/
Also, in order for the animation to work in mozilla and opera you'll need to add the -moz- and -o- prefixes as well.
ie:
.content1{
width: 1280px;
height: 322px;
}
.message{
width: 1240px;
height: 94px;
background-color:#5292a5;
margin: 25px 20px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.message1{
width: 1240px;
height: 94px;
font-size: 70px;
text-align:center;
color: white;
-webkit-animation-duration: 10s;
-webkit-animation-name: slidein;
-webkit-animation-iteration-count: infinite;
-webkit-animation-delay: forwards;
-webkit-animation-direction: normal;
-moz-animation-duration: 10s;
-moz-animation-name: slidein;
-moz-animation-iteration-count: infinite;
-moz-animation-delay: forwards;
-moz-animation-direction: normal;
-o-animation-duration: 10s;
-o-animation-name: slidein;
-o-animation-iteration-count: infinite;
-o-animation-delay: forwards;
-o-animation-direction: normal;
animation-duration: 10s;
animation-name: slidein;
animation-iteration-count: infinite;
animation-delay: forwards;
animation-direction: normal;
}
#-webkit-keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
#-moz-keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
#-o-keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
#keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
Demo in a fiddle: http://jsfiddle.net/swh2jqrg/3/
Or you can use another method with text-indent and text-shadow to have no wholes in between each loops :DEMO
.message{
width: 1240px;
background-color:#5292a5;
margin: 25px 20px;
border-radius: 5px;
overflow:hidden;
text-shadow:0 0 2px red, 1240px 0 , 1240px 0 2px blue;/* pick here another color for text mirrored */
animation:slidein infinite 10s linear;
font-size:60px;
color:turquoise;
line-height:94px;
}
.message1 {
display:inline-block;
width:100%;
text-indent:0;
}
#keyframes slidein {
from {
text-indent:-100%;
}
to {
text-indent:0%;
}
}
You need to add vendor prefix -webkit- for Chrome/Opera/Safari. Check CanIuse?
CSS
.message1{
width: 1240px;
height: 94px;
font-size: 70px;
text-align:center;
color: white;
-webkit-animation-duration: 10s;
-webkit-animation-name: slidein;
-webkit-animation-iteration-count: infinite;
-webkit-animation-delay: forwards;
-webkit-animation-direction: normal;
animation-duration: 10s;
animation-name: slidein;
animation-iteration-count: infinite;
animation-delay: forwards;
animation-direction: normal;
}
#-webkit-keyframes slidein {
from {
margin-left: 0%;
width: 300%;
height:94px;
}
to {
margin-left: 100%;
width: 1240px;
height:94px;
}
}
JSFiddle DEMO