jquery - Cross fading images javascript -
i have 1 image:
clown%20fish
onmouseover have show image:
image.jpeg
that on image:
energy.jpeg
(show webkit-transition: opacity 1s ease-in-out property)
i got first code form here : http://css3.bradshawenterprises.com/cfimg/#comments
dose not works...
this live demo: http://liveweave.com/6egbyh
here code:
<!doctype html> <html> <head> <style> #cfnormal { position:relative; height:281px; width:450px; margin:0 auto; } #cf { position:relative; height:10px; width:450px; margin:0 auto; } #cf img { position:absolute; left:0; width:450px; -webkit-transition: opacity 1s ease-in-out; -moz-transition: opacity 1s ease-in-out; -o-transition: opacity 1s ease-in-out; transition: opacity 1s ease-in-out; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script> <script> function change(x) { var element = document.getelementbyid('imgtop'); element.style.opacity = "0"; } </script> </head> <body> <div id="cf"> <img id="imgbott" class="bottom" src="./image.jpeg" /> <img id="imgtop" class="top" src="./energy.jpeg" /> </div> <div id="cfnormal"> <img onmouseover="change(this)" src="./clown%20fish.jpg" /> </div> </body> </html>
i had show 1 image on when third image fire event on mouseover
here correct code:
<!doctype html> <html> <head> <style> #cfnormal { position:relative; height:281px; width:450px; margin:0 auto; } #cfnormal img { position:relative; height:281px; width:450px; margin:0 auto; } #cf { position:relative; height:10px; width:450px; margin:0 auto; } #cf img { position:absolute; left:0; width:450px; -webkit-transition: opacity 1s ease-in-out; -moz-transition: opacity 1s ease-in-out; -o-transition: opacity 1s ease-in-out; transition: opacity 1s ease-in-out; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script> <script> function change(x) { var element = document.getelementbyid('imgtop'); element.style.opacity = "0"; } function normalimg(x) { var element = document.getelementbyid('imgtop'); element.style.opacity = "1"; } </script> </head> <body> <div id="cf"> <img id="imgbott" class="bottom" src="http://youngsskatingcenter.com/nss- folder/pictures/many_colors.gif" /> <img id="imgtop" class="top" src="http://freepages.genealogy.rootsweb.ancestry.com/~genphotos2/jwline.jpg" /> </div> <div id="cfnormal"> <img onmouseover="change(this)" onmouseout="normalimg(this)" src="http://www.vmapas.com/maps/2748-2/immagine_satellitare_mondo_occidentale.jpg" /> </div> </body> </html>
Comments
Post a Comment