I am trying to load in separate elements in a list at different times.
The bird top left should be first, followed by the background and then the other elements.
https://imgur.com/a/Z4vKcEv
As you can see in this gif, the elements are fading in at times different than i expected. Anyone know why?
EDIT: If GIF does not load, the last element in the list loads first, and then the other elements load in order.
Here is my code:
HTML:
<ul class="anim">
<li class="logo">
<img src="imgs/bird.jpg">
</li>
<li class="fullscreen-bg">
<img class="fullscreen-bg__img" src="imgs/rockymountains.jpg">
</li>
<li class="green1">
<h1>ESTUDO</h1>
</li>
<li class="green2">
<h1>ESTUDO E TRABALHO</h1>
</li>
<li class="green3">
<h1>IMIGRAÇÃO</h1>
</li>
</div>
<li class="red">
<h1>SEU SONHO, NOSSA MISSÃO</h1>
</li>
</ul>
CSS
/* TEXT ANIMATIONS */
li {
opacity: 0;
animation: fadeIn 3.5s 1;
animation-fill-mode: forwards;
}
.anim li:nth-child(1) { animation-delay: 1s }
.anim li:nth-child(2) { animation-delay: 1.5s }
.anim li:nth-child(3) { animation-delay: 2s }
.anim li:nth-child(4) { animation-delay: 2.8s }
.anim li:nth-child(5) { animation-delay: 3.4s }
/*...*/
#keyframes fadeIn {
0% {
opacity: 0.0;
}
100% {
opacity: 1.0;
}
}
/* END TEXT ANIMATIONS */
From what i can tell all the children in the list are set properly. Thanks in advance for your help.
You have 6 "li" elements in your source but you have only set animation-delay for 1-5, that is why the 6th "li" do not have delay and will display first. Add in 1 more delay for that element will make it OK:
li {
opacity: 0;
animation: fadeIn 3.5s 1s;
animation-fill-mode: forwards;
}
.anim li:nth-child(1) { animation-delay: 1s }
.anim li:nth-child(2) { animation-delay: 1.5s }
.anim li:nth-child(3) { animation-delay: 2s }
.anim li:nth-child(4) { animation-delay: 2.5s }
.anim li:nth-child(5) { animation-delay: 3s }
.anim li:nth-child(6) { animation-delay: 3.5s }
/*...*/
#keyframes fadeIn {
0% {
opacity: 0.0;
}
100% {
opacity: 1.0;
}
}
Related
I was trying to make a gradual fadein using normal CSS and no jquery on a list so it can fade in one-by-one. However, I only know how to do it in a limited amount of list. How do I loop the css so no matter how much list I have it still works.
Here is what I have done:
.ladder {
opacity: 0;
-webkit-animation: fadeIn 0.9s 1;
animation: fadeIn 0.9s 1;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.ladder:nth-child(5n+1) {
-webkit-animation-delay: 0.2s;
animation-delay: 0.2s;
}
.ladder:nth-child(5n+2) {
-webkit-animation-delay: 0.4s;
animation-delay: 0.4s;
}
.ladder:nth-child(5n+3) {
-webkit-animation-delay: 0.6s;
animation-delay: 0.6s;
}
.ladder:nth-child(5n+4) {
-webkit-animation-delay: 0.8s;
animation-delay: 0.8s;
}
.ladder:nth-child(5n+5) {
-webkit-animation-delay: 1.0s;
animation-delay: 1.0s;
}
#-webkit-keyframes fadeIn {
0% {
opacity: 0.0;
}
100% {
opacity: 1.0;
}
}
#keyframes fadeIn {
0% {
opacity: 0.0;
}
100% {
opacity: 1.0;
}
}
<li class="ladder">A</li>
<li class="ladder">B</li>
<li class="ladder">C</li>
<li class="ladder">D</li>
<li class="ladder">E</li>
My question: How to make the css to work on no matter how much list there is.
Here is an idea using CSS variable that allow you to reduce the code. It's not generic but it's more easier to append a simple inline CSS to each li than writing complex CSS:
.ladder {
opacity: 0;
animation: fadeIn 1s var(--d) forwards;
}
#keyframes fadeIn {
100% {
opacity: 1;
}
}
<ul>
<li style="--d:0s" class="ladder">A</li>
<li style="--d:0.2s" class="ladder">B</li>
<li style="--d:0.4s" class="ladder">C</li>
<li style="--d:0.6s" class="ladder">D</li>
<li style="--d:0.8s" class="ladder">E</li>
</ul>
Here is another idea where you can apply an animation on the ul:
ul {
position:relative;
}
ul:before {
content:"";
position:absolute;
top:-20px;
bottom:0;
left:0;
right:0;
background:linear-gradient(to bottom,transparent,#fff 20px);
animation:fadeIn 2s forwards
}
#keyframes fadeIn {
0% {
top:-10px;
}
100% {
top: 100%;
}
}
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
<li>D</li>
<li>E</li>
</ul>
I'm not very familiar with css nor css animations. I have made a fade-in animation for some pictures. They do work great, but not on an old Safari browser.
A friend of mine uses Safari 5.1.10 and the pictures don't get displayed.
What can I do that it will play the animation or how can I tell the browser "if you're too old for that stuff then just ignore the animation and display the pictures"?
And here is the css:
.column-image > div picture > img{
opacity: 0;
animation-name: fadein;
animation-duration: 3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
#c1163 > div > div:nth-child(2) > div picture > img{
animation-delay: 0.5s;
}
#c1163 > div > div:nth-child(6) > div picture > img{
animation-delay: 1s;
}
#c1163 > div > div:nth-child(7) > div picture > img{
animation-delay: 1.5s;
}
#c1163 > div > div:nth-child(11) > div picture > img{
animation-delay: 2s;
}
#c1163 > div > div:nth-child(12) > div picture > img{
animation-delay: 2.5s;
}
#keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-moz-keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-webkit-keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-o-keyframes fadein {
from {
opacity:0;
}
to {
opacity: 1;
}
}
This is because you need to add vendor prefixes to the animation attributes because in older versions they're considered 'experimental'. Check out the support for Animations on Can I Use? Safari 5.1 requires the -webkit- prefix.
You code should work when changed to the following:
.column-image > div picture > img{
opacity: 0;
animation-name: fadein;
animation-duration: 3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
-webkit-animation-name: fadein;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: 1;
-webkit-animation-fill-mode: forwards;
}
#c1163 > div > div:nth-child(2) > div picture > img{
animation-delay: 0.5s;
-webkit-animation-delay: 0.5s;
}
#c1163 > div > div:nth-child(6) > div picture > img{
animation-delay: 1s;
-webkit-animation-delay: 1s;
}
#c1163 > div > div:nth-child(7) > div picture > img{
animation-delay: 1.5s;
-webkit-animation-delay: 1.5s;
}
#c1163 > div > div:nth-child(11) > div picture > img{
animation-delay: 2s;
-webkit-animation-delay: 2s;
}
#c1163 > div > div:nth-child(12) > div picture > img{
animation-delay: 2.5s;
-webkit-animation-delay: 2.5s;
}
#keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-moz-keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-webkit-keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-o-keyframes fadein {
from {
opacity:0;
}
to {
opacity: 1;
}
}
The opacity attribute is okay and has pretty good support and that does not have a prefix to add. There are other vendor prefixes for other browsers too as you've used already, but you'll be fine with just the webkit prefix for the animation ones (keep the prefixed keyframe prefixes though).
I am using a css code to fade in and then fade out an html div, and after a delay, fade in another div. However, after the second div fades in and the code ends, the first div reappears. The code I am using is posted below. I wanted to know how to make sure the first div dosent reappear after the code ends.
.text {
-webkit-animation: fadein 5s
}
#-webkit-keyframes fadein {
0% {
opacity: 0;
}
35% {
opacity: 1;
}
72% {
opacity:1;
}
100% {
opacity:0;
}
}
#-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; } }
.bdy {
opacity:0; /* make things invisible upon start */
-webkit-animation:fadeIn ease-in 1; /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:1s;
-moz-animation-duration:1s;
animation-duration:1s;
}
.bdy {
-webkit-animation-delay: 4.5s;
-moz-animation-delay: 4.5s;
animation-delay: 4.5s;
}
HTML:
<header>
<div class="text_paragraph">
<h1>DEMO</h1>
<h3>Secondary School</h3>
<h3>Grade</h3>
</div>
<div class="bdy">
<h1>hi</h1>
</div>
</header>
You can do something like this ... here is a jsFiddle
Obs: Add the other css selectors besides -webkit- to make it cross-browser
CSS
.text_paragraph {
-webkit-animation: fadeInOut 2s;
opacity:0;
}
.bdy {
-webkit-animation:fadeIn 3s;
}
#-webkit-keyframes fadeInOut{
0% {
opacity: 0;
}
35% {
opacity: 1;
}
72% {
opacity:1;
}
100% {
opacity:0;
}
}
#-webkit-keyframes fadeIn{
0% {
opacity: 0;
}
75% {
opacity:0;
}
100% {
opacity:1;
}
}
My Code for showing divs with fade-in effect is as here
#-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; } }
.fade-in {
opacity:0;
-webkit-animation:fadeIn ease-in 1;
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:2s;
-moz-animation-duration:2s;
animation-duration:2s;
}
.fade-in.one
{
-webkit-animation-delay: 1.7s;
-moz-animation-delay: 1.7s;
animation-delay: 1.7s;
}
Then i am using that to a div which needs to fade in while loading.
<div class="fade-in one">
<label>Message Box</label>
This box will show some messages
</div>
This code works fine in chrome and firefox as well, but in ie it is showing no animation.
Kindly help in fixing this problem. I have tried many changes in the code, and IE versions as well. But no joy. Please help ....
I am trying to load an unordered list with animation using CSS3 keyframe.
My problem is the list get loaded before the animation begun.
And I want it to load only after the animation.
here is a result of what I achieved so far http://jsbin.com/agelix/1/edit
HTML
<ul
class="loadingdiv" >
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
CSS
.loadingdiv li{
-moz-animation: loading 1s alternate;
}
.loadingdiv li:nth-of-type(2) {
-moz-animation-delay: 0.4s;
}
.loadingdiv li:nth-of-type(3) {
-moz-animation-delay: 0.6s;
}
.loadingdiv li:nth-of-type(4) {
-moz-animation-delay: 0.8s;
}
.loadingdiv li:nth-of-type(5) {
-moz-animation-delay: 0.9s;
}
#-moz-keyframes loading {
0% {-moz-transform: translateZ(0); opacity:0}
}
OK, after lot click click click... and some info from css3files.com, It worked.
DEMO: http://jsbin.com/ehujis/1/edit
her is what I did.
HTML:
<ul>
<li class="box fade-in">1</li>
<li class="box fade-in">2</li>
<li class="box fade-in">3</li>
<li class="box fade-in">4</li>
</ul>
CSS:
/* make keyframes that tell the start state and the end state of our object */
#keyframes fadeIn {
from { opacity:0; }
to { opacity:1; } }
.fade-in {
opacity:0; /* make things invisible upon start */
animation:fadeIn ease-out 3s;
animation-fill-mode:forwards;
animation-duration:.8s;
}
li:nth-of-type(1) {
animation-delay: 0.6s;
}
li:nth-of-type(2) {
animation-delay: 1.3s;
}
li:nth-of-type(3) {
animation-delay: 2s;
}
li:nth-of-type(4) {
animation-delay: 2.7s;
}
Note: this code is based from the graphicfusiondesign.com article: Creating fancy CSS3 fade in animations on page load
here is a demo