[英]Fading background images with jQuery/css?
我有以下腳本(從這里)加載圖像並將其設置為背景。 它工作得很好,但是我需要改變什么來添加一張以上的照片,這樣它就可以成為幻燈片了?
jQuery:
$(document).ready(function(){
$.fn.smartBackgroundImage = function(url){
var t = this;
//create an img so the browser will download the image:
$('<img />')
.attr('src', url)
.load(function(){ //attach onload to set background-image
t.each(function(){
$(this).css('backgroundImage', 'url('+url+')' );
});
});
return this;
}
$('body').smartBackgroundImage('/static/images/temp-bg.jpg');
});
謝謝!
將您的圖像合並到帶有<li>
標簽的 html 中,並使用 jquery 對其進行格式化。 所以以后更容易改變它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.