I have created a text fadein-fadeout animation for 4 lines of text.
The lines appear one after another and so far, that's fine.
Now it's requested to to an infinite loop on all these animations.
As I am pretty new to css animations I really don't know how to handle this.
I guess I might have setup the whole thing wrong. But how can it be rebuilt, so that I have an infinite animation of all 4 lines?
Thanks for any hint!
PS: I attach the code snippet and here is the Fiddle as well for those, who prefer that: https://codepen.io/SchweizerSchoggi/pen/xxKXyyv
PS2: my question is close or similiar to another question asked 5 years ago by another user, but that one did not get an answer. That's why I asked MY question here and today. At least I got an answer that helped.
body {
font-size: 62.5%;
font-family: Arial;
}
.animation-box {
width: 75%;
height: 30rem;
background-color: darkblue;
margin: 0 auto;
overflow: hidden;
position: relative;
}
#keyframes fadeInOut {
0% {
opacity: 0;
}
45% {
opacity: 1;
}
100% {
opacity: 0%;
}
}
.animation-box h1 {
position: absolute;
left: 5%;
top: 0;
font-size: 4em;
color: white;
font-weight: 400;
}
.first-line,
.second-line,
.third-line,
.fourth-line {
font-size: 3em;
position: absolute;
left: 5%;
top: 20%;
opacity: 0;
color: rgba(200,200,200,0.9);
}
.first-line {
animation-name: fadeInOut;
animation-duration: 5s;
}
.second-line {
animation-name: fadeInOut;
animation-delay: 5s;
animation-duration: 5s;
}
.third-line {
animation-name: fadeInOut;
animation-delay: 10s;
animation-duration: 5s;
}
.fourth-line {
animation-name: fadeInOut;
animation-delay: 15s;
animation-duration: 5s;
}
<section class="animation-box">
<h1>Fading the lines</h1>
<div class="first-line">This is line 1</div>
<div class="second-line">here comes line 2</div>
<div class="third-line">3 is the perfect number</div>
<div class="fourth-line">the final one is 4</div>
</section>
How it works?
1: Animation duration / no. of elements = animation delay
2: You need to tweak keyframe animation as per your requirements(this may vary). You need have instinct on time appearance of your each element & time gap.
3: And add animation-iteration-count: infinite; to your individual element.
body {
font-size: 62.5%;
font-family: Arial;
}
.animation-box {
width: 75%;
height: 30rem;
background-color: darkblue;
margin: 0 auto;
overflow: hidden;
position: relative;
}
#keyframes fadeInOut {
0% {
opacity: 0;
}
2% {
opacity: 0;
}
5% {
opacity: 1;
}
17% {
opacity: 1;
}
19% {
opacity: 1;
}
24% {
opacity: 0;
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
.animation-box h1 {
position: absolute;
left: 5%;
top: 0;
font-size: 4em;
color: white;
font-weight: 400;
}
.first-line,
.second-line,
.third-line,
.fourth-line {
font-size: 3em;
position: absolute;
left: 5%;
top: 20%;
opacity: 0;
color: rgba(200,200,200,0.9);
animation-name: fadeInOut;
animation-iteration-count: infinite;
}
.first-line {
animation-duration: 12s;
}
.second-line {
animation-delay: 3s;
animation-duration: 12s;
}
.third-line {
animation-delay: 6s;
animation-duration: 12s;
}
.fourth-line {
animation-delay: 9s;
animation-duration: 12s;
}
<section class="animation-box">
<h1>Fading the lines</h1>
<div class="first-line">This is line 1</div>
<div class="second-line">here comes line 2</div>
<div class="third-line">3 is the perfect number</div>
<div class="fourth-line">the final one is 4</div>
</section>
Related
Loading icon not spinning in the iOS version > 15.3 or 16.1 but it is working fine in the lower < 15 iOS version iphone and ipad and Android, browser.
Please find the below css code for reference. i have tried with webkit for safari and also tried with transform: rotate(-360deg). but spinner is not spinning/rotating in the iOS device alone. could you please confirm what we can change from our end.
#keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
/* spinner Wrapper */
.Wrapperspinner{
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 9999;
line-height: 30px;
margin-left: 0;
margin-top: 0;
text-align: center;
color: #fff;
padding-top: 7px;
background-color: rgba(250, 250, 250, 0.8);
opacity: 0.8;
display: none;
}
.loading {
position: absolute;
top: 50%;
left: 50%;
width: 80px;
height: 110px;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%)
}
/* Spinning circle (inner circle) */
.loading .maskedCircle {
width: 80px;
height: 80px;
border-radius: 50%;
border: 3px solid #ff6969;
}
/* Spinning circle mask */
.loading .mask {
width: 25px;
height: 25px;
overflow: hidden;
margin: -3px;
}
/*waiting text*/
.loading .spinnerWaitingText {
position: absolute;
bottom: 0;
text-align: center;
width: 100%;
}
/* Spinner */
.loading .spinner {
position: absolute;
left: 0;
top: 0;
width: 80px;
height: 80px;
animation-name: spin;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: linear;
-webkit-animation-name: spin;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
border-radius: 50%;
border: 3px solid #12779a;
}
div.tc-screenMask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1000;
background-color: #000;
opacity: 0.3;
display: none;
}
.SpinnerStep1,
.SpinnerStep2,
.SpinnerStep3{
opacity: 0;
text-align: center;
position: absolute;
width: 100%;
}
.SpinnerContainer{
position: fixed;
top: calc(50% + 90px);
width: 100%;
left: 50%;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
min-width: 300px;
visibility: hidden;
}
.SpinnerStep1 {
animation-name: fadeInOut1;
animation-duration: 3s;
animation-timing-function: linear;
animation-iteration-count: 1;
-webkit-animation-name: fadeInOut1;
-webkit-animation-duration: 3s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: 1;
}
.SpinnerStep2 {
animation-name: fadeInOut2;
animation-duration: 6s;
animation-timing-function: linear;
animation-iteration-count: 1;
-webkit-animation-name: fadeInOut2;
-webkit-animation-duration: 6s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: 1;
}
.SpinnerStep3 {
animation-name: fadeInOut3;
animation-duration: 9s;
animation-timing-function: linear;
animation-iteration-count: 1;
animation-fill-mode: forwards;
-webkit-animation-name: fadeInOut3;
-webkit-animation-duration: 9s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: 1;
-webkit-animation-fill-mode: forwards;
}
#keyframes fadeInOut1 {
0% { opacity: 0 }
1% { opacity: 1 }
95% {opacity: 1 }
100% { opacity: 0 }
}
#keyframes fadeInOut2 {
0% { opacity: 0 }
50% { opacity: 0 }
51% { opacity : 1}
95% { opacity: 1 }
100% { opacity: 0 }
}
#keyframes fadeInOut3 {
0% { opacity: 0 }
66% { opacity: 0 }
67% { opacity: 1 }
100% { opacity: 1 }
}
#-webkit-keyframes fadeInOut1 {
0% { -webkit-opacity: 0 }
1% { -webkit-opacity: 1 }
95% {-webkit-opacity: 1 }
100% { -webkit-opacity: 0 }
}
#-webkit-keyframes fadeInOut2 {
0% { -webkit-opacity: 0 }
50% { -webkit-opacity: 0 }
51% { -webkit-opacity : 1}
95% { -webkit-opacity: 1 }
100% { -webkit-opacity: 0 }
}
#-webkit-keyframes fadeInOut3 {
0% { -webkit-opacity: 0 }
66% { -webkit-opacity: 0 }
67% { -webkit-opacity: 1 }
100% { -webkit-opacity: 1 }
}
.angSpinner.Wrapperspinner {
background-color: #fff;
opacity: 0.9;
display: block;
visibility: hidden;
}
.angSpinner .loading {
width: 148px;
height: 148px;
}
.angSpinner .loading .spinner {
border: none;
width: 148px;
height: 148px;
animation-name: spin;
animation-duration: .8s;
animation-iteration-count: infinite;
animation-timing-function: linear;
-webkit-animation-name: spin;
-webkit-animation-duration: .8s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
.angSpinner .loading .maskedCircle {
border: 4px solid #005900;
width: 140px;
height: 140px;
margin: 0;
box-sizing: content-box;
-webkit-box-sizing: content-box;
}
.angSpinner .loading .mask {
width: 148px;
height: 35px;
margin: 0;
}
please find the below HTML and Js code for reference. other animation text is for fade out in above css3 defined - delay. css3 code shared above for your reference. i have tried with above approach but sorry it is not working.
<div id="Wrapper" class="Wrapperspinner"
aria-label="Loading page now">
<div class="loading">
<!-- We make this div spin -->
<div class="spinner">
<!-- Mask of the quarter of circle -->
<div class="mask">
<!-- Inner masked circle -->
<div class="maskedCircle"></div>
</div>
</div>
<div class="loginSpinnerContainer" aria-hidden="true" tabindex="-1">
<div class="boi_label SpinnerStep1">
Contacting to server...
</div>
<div class="boi_label SpinnerStep2">
Authenticating your application...
</div>
<div class="boi_label SpinnerStep3">
Running security checks...
</div>
</div>
<div class="boi_label spinnerWaitingText" aria-hidden="true" tabindex="-1">please wait</div>
</div>
</div>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
SLoader.setup({
id: 'WRAPPER',
showMask: 'WRAPPER.CREATE_MASK',
delay: '5'
});
$(document).ready(function() {
SLoader.triggerHide();
$('.main-form').attr('aria-hidden', 'false');
});
Hi.addHook('beforeSubmit', showSpinnerOnSubmit);
Hi.addHook('beforeAjaxButtonActionService', showSpinnerForAjaxButton);
Hi.addHook('postProcessResponse', SLoader.triggerHide);
function showSpinnerOnSubmit(){
$('#WRAPPER$').attr({'role': 'alert', 'aria-live': 'assertive'});
$('.main-form').attr('aria-hidden', 'true');
SLoader.triggerShow();
}
function showLoginSpinner(){
$('.loginSpinnerContainer').css('visibility', 'visible');
$('.spinnerWaitingText').hide();
$('#WRAPPER$').addClass('customSpinner');
}
function showSpinnerForAjaxButton() {
if(document.activeElement.classList.contains('showSpinner_ajaxbutton')) {
SLoader.triggerShowAjax();
}
}
//]]>
</script>
I am making a simple animation in Codepen - the poem fades in, then the word (that is also the button) fades in. The user clicks on the word and it changes to the next part of the poem.
My problem is that the poem and single word with flash before the fade out starts.
I have tried ALL the tricks I can find, adding:
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-webkit-transform:translate3d(0,0,0);
and none of them have worked.
Link to the codepen: https://codepen.io/zaenaria/pen/xWVLmP
$(".btnQuestion").hide();
var answer = document.getElementById('answerBtn');
answer.style.cursor = 'pointer';
answer.onclick = function() {
$(".poem").addClass("animationComplete");
$(".btnAnswer").addClass("animationComplete");
$(".answer").addClass("animationFade");
$(".btnQuestion").show();
$(".btnQuestion").addClass("animationFade");
};
var question = document.getElementById('questionBtn');
question.style.cursor = "pointer";
question.onclick = function() {
$(".answer").addClass("animationComplete");
$(".btnQuestion").addClass("animationComplete");
$(".question").addClass("animationFade");
$(".rip").addClass("animationRIP");
};
body {
background: url("http://res.cloudinary.com/zaenaria/image/upload/v1521062114/paper_texture.jpg");
background-repeat: no-repeat;
background-position: cover;
color: white;
}
.wrapper{
position: absolute;
top: 50%;
left: 50%;
}
.poem {
font-size: 30px;
font-family: 'Open Sans Condensed', sans-serif;
height: 300px;
width: 900px;
position: absolute;
margin: -150px 0 0 -450px;
opacity: 0;
animation-name: fade;
animation-delay: 0.5s;
animation-duration: 1.5s;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
}
.answer {
font-size: 30px;
font-family: 'Open Sans Condensed', sans-serif;
height: 160px;
width: 900px;
position: absolute;
margin: -80px 0 0 -450px;
opacity: 0;
}
.question {
font-size: 50px;
font-family: 'Open Sans Condensed', sans-serif;
height: 80px;
width: 400px;
position: absolute;
margin: -40px 0 0 -200px;
opacity: 0;
}
.rip {
font-size: 50px;
font-family: 'Open Sans Condensed', sans-serif;
text-align: center;
height: 140px;
width: 400px;
position: absolute;
margin: 25px 0 0 -200px;
opacity: 0;
}
.btnAnswer{
font-size: 50px;
font-family: 'Open Sans Condensed', sans-serif;
text-align: center;
height: 80px;
width: 180px;
position: absoulte;
margin: 200px 0 0 -100px;
opacity: 0;
animation-name: fade;
animation-delay: 2.0s;
animation-duration: 1.5s;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
}
.btnAnswer:hover {
background: #f7f7f7;
color: black;
}
.btnQuestion:hover {
background: #f7f7f7;
color: black;
}
.btnQuestion {
font-size: 50px;
font-family: 'Open Sans Condensed', sans-serif;
text-align: center;
height: 80px;
width: 180px;
position: absoulte;
margin: -150px 0 0 -90px;
opacity: 0;
}
#keyframes fade {
0% {opacity: 0;}
100% {opacity: 1;}
}
#keyframes complete {
0% {opacity: 1;}
100% {opacity: 0;}
}
.animationFade {
animation-name: fade;
animation-delay: 2.0s;
animation-duration: 1.5s;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
}
.animationComplete {
animation-name: complete;
animation-delay: 0.3s;
animation-duration: 1.0s;
animation-timing-function: ease-out;
animation-fill-mode: forwards;
}
.animationRIP {
animation-name: fade;
animation-delay: 4.0s;
animation-duration: 1.0s;
animation-timing-function: ease-in;
animation-fill-mode: forwards;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="wrapper">
<div class="poem">Oh me! Oh life! of the questions of these recurring, </br>
Of the endless trains of the faithless, of cities fill’d with the foolish, </br>
Of myself forever reproaching myself, (for who more foolish than I, and who more faithless?) </br>
Of eyes that vainly crave the light, of the objects mean, of the struggle ever renew’d, </br>
Of the poor results of all, of the plodding and sordid crowds I see around me, </br>
Of the empty and useless years of the rest, with the rest me intertwined, </br>
The question, O me! so sad, recurring—What good amid these, O me, O life?</div>
<div class="answer">
That you are here—that life exists and identity, </br>
That the powerful play goes on, and you may contribute a verse.</br>
~Walt Whitman
</div>
<div class="question">What will your verse be?
</div>
<div class="rip">R.I.P Robin Williams</br>
1951-2014</div>
<div class="btnAnswer" id="answerBtn">Answer.</div>
<div class="btnQuestion" id="questionBtn">Question.</div>
</div>
</body>
Try changing the animation start delay to 0 in the css:
.animationComplete {
animation-name: complete;
animation-delay: 0s;
animation-duration: 1.0s;
animation-timing-function: ease-out;
animation-fill-mode: forwards;
}
I changed the animation-fil-mode of .animationComplete to backwards and it did the trick :)
.animationComplete {
animation-name: complete;
animation-delay: 0.3s;
animation-duration: 1.0s;
animation-timing-function: ease-out;
animation-fill-mode: backwards;
}
Seem to be having a problem where the bezier numbers I put in are not actually having different effects on the rotation of an element. I will be rotating all 4 of these dots at different speeds over the same duration...stuck at even getting 2 to behave differently:
<div id="dotcontainer1" class="dotcont">
<div id="dot1" class="dot"></div>
</div>
<div id="dotcontainer2" class="dotcont">
<div id="dot2" class="dot"></div>
</div>
<div id="dotcontainer3" class="dotcont">
<div id="dot3" class="dot"></div>
</div>
<div id="dotcontainer4" class="dotcont">
<div id="dot4" class="dot"></div>
</div>
Styled like this:
body {
background-color: #414a5b;
}
.dotcont {
width: 200px;
height: 200px;
float: left;
}
.dot {
position: relative;
margin: 0 auto;
}
#dot1 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
}
#dot2 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
opacity: 0.75;
}
#dot3 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
opacity: 0.5;
}
#dot4 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
opacity: 0.25;
}
#dotcontainer1 {
-webkit-animation-name: spin1;
-webkit-animation-duration: 3000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier (0,0,0.58,1);
}
#-webkit-keyframes spin1 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#dotcontainer2 {
-webkit-animation-name: spin2;
-webkit-animation-duration: 3000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier (.42,0,1,1);
}
#-webkit-keyframes spin2 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
Here is a link to the pen: http://codepen.io/chris86/pen/jWqGvM?editors=110
I've edited your pen http://codepen.io/anon/pen/BjKmxR?editors=110
In order to create that effect I've used the following site that allows you to create whatever cubic-bezier you want:http://cubic-bezier.com/
The one I've used are:
cubic-bezier(.2,.78,.69,.86);
cubic-bezier(.95,.1,1,.85);
You need to change the animation duration
CSS
body {
background-color: #414a5b;
}
.dotcont {
width: 200px;
height: 200px;
float: left;
}
.dot {
position: relative;
margin: 0 auto;
}
#dot1 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
}
#dot2 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
opacity: 0.75;
}
#dot3 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
opacity: 0.5;
}
#dot4 {
width: 16px;
height: 16px;
border-radius: 8px;
background-color: #fff;
opacity: 0.25;
}
#dotcontainer1 {
-webkit-animation-name: spin1;
-webkit-animation-duration: 1000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier (0,0,0.58,1);
}
#-webkit-keyframes spin1 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#dotcontainer2 {
-webkit-animation-name: spin2;
-webkit-animation-duration: 2000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier (.42,0,1,1);
}
#-webkit-keyframes spin2 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#dotcontainer3 {
-webkit-animation-name: spin3;
-webkit-animation-duration: 3000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier (0,0,0.58,1);
}
#-webkit-keyframes spin3 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
#dotcontainer4 {
-webkit-animation-name: spin4;
-webkit-animation-duration: 4000ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier (.42,0,1,1);
}
#-webkit-keyframes spin4 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
I'm having issues in Chrome browser getting my animations to work correctly. Upon page load the first span in rw-words-1 is always off in its positioning for some reason. On the website when the page loads, it is supposed to read like...
Building "some text 1"
designed to "some word 1"
and then the words i've placed in quotes should fade out and the new words pop in like...
Building "some text 2"
designed to "some word 2"
etc, etc based on the html file below. The problem is the 2nd and 3rd span pop in the correct positioning, but the 1st span is always jumbled & overlapping the "designed to" text for some reason. It works fine however in Firefox / Safari. Any help would be much appreciated.
FRONT-END HTML
<div class="slogan">
<h1 class="rw-sentence">
<span>Building</span>
<div class="rw-words rw-words-1">
<span>some text 1...</span>
<span>some text 2...</span>
<span>some text 3...</span>
</div>
<br clear="all">
<span>designed to</span>
<div class="rw-words rw-words-2">
<span>some word 1</span>
<span>some word 2</span>
<span>some word 3</span>
</div>
</h1>
<p>Some sub-slogan here</p>
</div>
CSS:
/* ------ CSS ANIMATIONS ------- */
.rw-wrapper {
width: 90%;
padding: 10px;
}
.rw-sentence{
text-align: left;
position: relative;
}
.rw-sentence span {
white-space: nowrap;
}
.rw-words {
display: inline;
}
.rw-words span{
position: absolute;
opacity: 0;
width: 100%;
/* overflow: hidden; */
font-weight: bold;
}
.rw-words.rw-words-1 span {
margin-left: 0px;
}
/* -- WEIRD FIREFOX MARGIN HACK --*/
#-moz-document url-prefix() {
.rw-words.rw-words-1 span {
margin-left: 10px;
}
}
.rw-words.rw-words-2 span {
margin-left: 10px;
}
.rw-words-1 span{
animation: rotateWordsSecond 18s linear infinite 0s;
-webkit-animation: rotateWordsSecond 18s linear infinite 0s;
-moz-animation: rotateWordsSecond 18s linear infinite 0s;
-ms-animation: rotateWordsSecond 18s linear infinite 0s;
}
.rw-words-2 span{
animation: rotateWordsSecond 18s linear infinite 0s;
-webkit-animation: rotateWordsSecond 18s linear infinite 0s;
-moz-animation: rotateWordsSecond 18s linear infinite 0s;
-ms-animation: rotateWordsSecond 18s linear infinite 0s;
}
.rw-words span:nth-child(2) {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
}
.rw-words span:nth-child(3) {
-webkit-animation-delay: 12s;
-moz-animation-delay: 12s;
-ms-animation-delay: 12s;
animation-delay: 12s;
}
#keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#-moz-keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#-webkit-keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 1; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
#-moz-keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 1; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
#-webkit-keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 1; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
Well...I just changed some code around & added some margins/floats & it now works in all browsers. Still not sure why chrome treated the transitions/code from my original question differently though which is pretty frustrating. If anybody knows, i'd still love to know as I'm trying to get better at design that's consistent across all browsers. thx,
.rw-words {
display: inline;
float: left;
}
.rw-words span{
position: absolute;
opacity: 0;
width: 100%;
/* overflow: hidden; */
font-weight: bold;
}
.rw-words.rw-words-1 span {
margin-left: 165px;
font-weight: 480;
}
/* -- I REMOVED THE FIREFOX MARGIN HACK --*/
.rw-words.rw-words-2 span {
margin-left: 234px;
font-weight: 480;
}
I'm trying to animate the background-position of a div, slowly, but without it having jerky movement. You can see the result of my current efforts here:
http://jsfiddle.net/5pVr4/2/
#-webkit-keyframes MOVE-BG {
from {
background-position: 0% 0%
}
to {
background-position: 187% 0%
}
}
#content {
width: 100%;
height: 300px;
background: url(http://www.gstatic.com/webp/gallery/1.jpg) 0% 0% repeat;
text-align: center;
font-size: 26px;
color: #000;
-webkit-animation-name: MOVE-BG;
-webkit-animation-duration: 100s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
}
I have been at this for hours and can't find anything that will animate slowly and smoothly at a sub-pixel level. My current example was made from the example code on this page: http://css-tricks.com/parallax-background-css3/
The smoothness of animation I'm after can be seen on this page's translate() example:
http://css-tricks.com/tale-of-animation-performance/
If it can't be done with the background-position, is there a way to fake the repeating background with multiple divs and move those divs using translate?
Checkout this example:
#content {
height: 300px;
text-align: center;
font-size: 26px;
color: #000;
position:relative;
}
.bg{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: -1;
background: url(http://www.gstatic.com/webp/gallery/1.jpg) 0% 0% repeat;
animation-name: MOVE-BG;
animation-duration: 100s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
#keyframes MOVE-BG {
from {
transform: translateX(0);
}
to {
transform: translateX(-187%);
}
}
<div id="content">Foreground content
<div class="bg"></div>
</div>
http://jsfiddle.net/5pVr4/4/
Animating background-position will cause some performance issues. Browsers will animate transform properties much cheaply, including translate.
Here is an example using translate for an infinite slide animation (without prefixes):
http://jsfiddle.net/brunomuller/5pVr4/504/
#-webkit-keyframes bg-slide {
from { transform: translateX(0); }
to { transform: translateX(-50%); }
}
.wrapper {
position:relative;
width:400px;
height: 300px;
overflow:hidden;
}
.content {
position: relative;
text-align: center;
font-size: 26px;
color: #000;
}
.bg {
width: 200%;
background: url(http://www.gstatic.com/webp/gallery/1.jpg) repeat-x;
position:absolute;
top: 0;
bottom: 0;
left: 0;
animation: bg-slide 20s linear infinite;
}
You should adjust your HTML and CSS little bit
Working Demo
HTML
<div id="wrapper">
<div id="page">
Foreground content
</div>
<div id="content"> </div>
</div>
CSS
#-webkit-keyframes MOVE-BG {
from { left: 0; }
to { left: -2000px; }
}
#wrapper {
position:relative;
width:800px;
height: 300px;
overflow:hidden;
}
#page {
text-align: center;
font-size: 26px;
color: #000;
}
#content {
width: 2000px;
height: 300px;
background: url(http://www.gstatic.com/webp/gallery/1.jpg) 0% 0% repeat;
position:absolute;
top: 0;
left: 0;
z-index:-1;
-webkit-animation-name: MOVE-BG;
-webkit-animation-duration: 100s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
}