我喜欢做这样的:
HTML:
<div id='lb_background'></div>
<div id='lb_front'>This is where your content will go!<div id="countdown"></div></div>
CSS:
#lb_background {
position: absolute; /*THIS IS REQUIRED!*/
height: 100%;
width: 100%;
background-color: black;
z-index: 1000; /* In front of everything */
opacity: 0.6;
}
#lb_front {
padding: 20px;
z-index: 1001; /* In front of lb_background */
position: absolute;
top: 50px;
}
的Jquery:
$('#lb_background').click(function(){
$('#lb_background, #lb_front').fadeOut(200)
});
编辑 以上就是我用来轻松创建灯箱的内容。至于倒数和计时器略有不同。
JQuery的:
$(function(){
var count = 10;
countdown = setInterval(function(){
$("#countdown").html(count + " seconds remaining!");
if (count == 0) {
$('#lb_background, $lb_front').fadeOut(200);
}
count--;
}, 1000);
});
(来源:How can I make a jQuery countdown)
我最喜欢的眼中钉。 – 2012-02-27 23:44:03