Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an image / div fade with CSS3, without using a hover

I have a div with an image in it. At the moment I use CSS3 animation to fade it off, but the performance is terrible.

I am pretty sure I should be using transitions. Problem is I cannot find one example that isn't triggered by a hover.

How can I make it so that when the page is loaded, after a delay of 2 seconds, the image/div fades in from 0%?

At the moment, as I said with animation, I have:

@-webkit-keyframes fadetime {
from {
 opacity: 0;
}

50% {
 opacity: 0;
}

to {
 opacity: 1;
    }
}

Any ideas? Thank you.

like image 898
user397466 Avatar asked Dec 16 '22 23:12

user397466


1 Answers

@-webkit-keyframes FadeIn {
    0% {
        opacity:0;
    }
    100% {
        opacity:1;
    }
}

.object {
    -webkit-animation-name: FadeIn;
    -webkit-animation-timing-function: ease-in;
    -webkit-animation-duration: 3s;
}
like image 130
Michael Martin Avatar answered Dec 29 '22 05:12

Michael Martin