$(document).ready(function () { var size = 50; //tamaño de cada flash (tamaño de la imagen) var speed = 200; //velocidad de reflejo (cuanto tarda en desaparecer) var cantidad = 300; setInterval(function () { var w = window.innerWidth; var h = window.innerHeight; var e = document.createElement("span"); $(e).css("display", "inline-block"); $(e).css("width", size + "px"); $(e).css("height", size + "px"); $(e).css("background", "url('http://i1317.photobucket.com/albums/t632/edjogore/resplandor1_zps8e724430.png')"); $(e).css("position", "fixed"); $(e).css("top", random(0, h) + "px"); $(e).css("left", random(0, w) + "px"); $(e).css("z-index", "1000"); $(e).animate({ opacity: 0 }, speed, function () { // oculta el elemento $(this).remove(); //eliminar el elemento }); $("html").append(e); }, cantidad); }); function random(min, max) { return Math.floor((Math.random() * max) + min); }
body{background:#000;}