Ciao a tutti, è possibile che il div di testo compaia con un effetto "fade in" al caricamento della pagina usando solo CSS3? (no js)
Vi chiedo questoperchè in tutti gli esempi che trovo in internet questo effetto è associato ad un stao :hover
Grazie
Ciao a tutti, è possibile che il div di testo compaia con un effetto "fade in" al caricamento della pagina usando solo CSS3? (no js)
Vi chiedo questoperchè in tutti gli esempi che trovo in internet questo effetto è associato ad un stao :hover
Grazie
un esempio:
codice HTML:... <style type="text/css"> <!-- #mioDiv { background-color: #CC99FF; width:400px; height:300px;/* puramente indicativi */ -webkit-animation: fadein 5s; -moz-animation: fadein 5s; -ms-animation: fadein 5s; -o-animation: fadein 5s; animation: fadein 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; } } @-ms-keyframes fadein { from { opacity: 0; } to { opacity: 1; } } @-o-keyframes fadein { from { opacity: 0; } to { opacity: 1; } } --> </style> </head> <body> <div id="mioDiv"></div> ...
Grazie molto gentile… se posso approfittare perchè con questo codice non funziona?
@-webkit-keyframes fadeInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-20px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
}
}
@-moz-keyframes fadeInLeft {
0% {
opacity: 0;
-moz-transform: translateX(-20px);
}
100% {
opacity: 1;
-moz-transform: translateX(0);
}
}
@-ms-keyframes fadeInLeft {
0% {
opacity: 0;
-ms-transform: translateX(-20px);
}
100% {
opacity: 1;
-ms-transform: translateX(0);
}
}
@-o-keyframes fadeInLeft {
0% {
opacity: 0;
-o-transform: translateX(-20px);
}
100% {
opacity: 1;
-o-transform: translateX(0);
}
}
@keyframes fadeInLeft {
0% {
opacity: 0;
transform: translateX(-20px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
.fadeInLeft {
background-color: #CC99FF; width:400px; height:300px;/* puramente indicativi */
-webkit-animation-name: fadeInLeft;
-moz-animation-name: fadeInLeft;
-ms-animation-name: fadeInLeft;
-o-animation-name: fadeInLeft;
animation-name: fadeInLeft;
}
<body>
<div class="fadeInLeft">Ciao</div>
</body>
Prova a dare un'occhiata a questo tool:
http://blog.html.it/20/02/2014/gener...ss3-animation/
Veramente utile!!!!!
Ma l'ho provato per creare un'adnimazione fadein da sinistra e nella preview del tool funziona, ma se la metto in un nuovo file html la vedo solo come un semplice fade in da opacità 0 a 1 senza spostamento da sinistra a destra. Perche???
non c'è verso che funzioni
Questo è qullo che ho modificato (la parte dei keyframe non l'ho toccata)
codice HTML:.fadeInLeft { background-color: #CC99FF; width:400px; height:300px;/* puramente indicativi */ -webkit-animation-name: fadeInLeft; -moz-animation-name: fadeInLeft; -ms-animation-name: fadeInLeft; -o-animation-name: fadeInLeft; animation-name: fadeInLeft; animation-duration: 5s; /* l'ho provato anche a scrivere in questo modo -> fadeInLeft 5s */ -webkit-animation-duration: 5s; /* l'ho provato anche a scrivere in questo modo -> fadeInLeft 5s */ } <body> <div style="margin: 0 100; background-color:#FCC; padding:30px" <div class="fadeInLeft">Ciao</div> </body>
A me funziona senza problemi (firefox, chrome e safari, non ho testato con Opera ma dovrebbe andare anche lì, con IE dovrebbe andare con la versione 11).
Il codice è esattamente quello, comunque te lo reinserisco tutto:
codice HTML:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento senza titolo</title> <style type="text/css"> <!-- @-webkit-keyframes fadeInLeft { 0% { opacity: 0; -webkit-transform: translateX(-20px); } 100% { opacity: 1; -webkit-transform: translateX(0); } } @-moz-keyframes fadeInLeft { 0% { opacity: 0; -moz-transform: translateX(-20px); } 100% { opacity: 1; -moz-transform: translateX(0); } } @-ms-keyframes fadeInLeft { 0% { opacity: 0; -ms-transform: translateX(-20px); } 100% { opacity: 1; -ms-transform: translateX(0); } } @-o-keyframes fadeInLeft { 0% { opacity: 0; -o-transform: translateX(-20px); } 100% { opacity: 1; -o-transform: translateX(0); } } @keyframes fadeInLeft { 0% { opacity: 0; transform: translateX(-20px); } 100% { opacity: 1; transform: translateX(0); } } .fadeInLeft { animation-name: fadeInLeft; -webkit-animation-name: fadeInLeft; -moz-animation-name: fadeInLeft; -ms-animation-name: fadeInLeft; -o-animation-name: fadeInLeft; -webkit-animation-duration:5s; animation-duration: 5s; width:400px; height:400px; background-color:#0099FF } --> </style> </head> <body><div class="fadeInLeft">Ciao</div> </body> </html>
Ora funziona anche a me !?
Provo a spulciare il codice per capire perchè non funzionava.
Grazie![]()
mi sono accorto che se cancello lo stile dell'animazione "fadein"
funziona tutto!!! Ora mi piacerebbe scoprire il motivo…codice HTML:#mioDiv { background-color: #CC99FF; width:400px; height:300px;/* puramente indicativi */ -webkit-animation: fadein 5s; -moz-animation: fadein 5s; -ms-animation: fadein 5s; -o-animation: fadein 5s; animation: fadein 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; } } @-ms-keyframes fadein { from { opacity: 0; } to { opacity: 1; } } @-o-keyframes fadein { from { opacity: 0; } to { opacity: 1; } }