Jumat, 24 Januari 2014

Cara membuat background slide show

 
Background Slide Show adalah gambar latar belakang yang bisa berganti-ganti secara otomatis setiap waktu yang telah ditentukan. Background ini disematkan di bagian body dengan posisi 100%.


Background Slide Show ini pertama-tama harus di load dengan JQuery yang biasanya dipasang di atas </head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js' type='text/javascript'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js' type='text/javascript'></script>

Setelah itu dibagian CSS body, minimal harus ada seperti ini:
body {
   background: black url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGKzt0Mpb3b04tVt_t4B-tXRTmuML73XYOgg73PzWhTr2SKtz4xTGp7YfXOnFDXlncakOiVUhRmNXTk567ZIxlWzjv1I1pUekcZtI7JSqxhMXElmUfVYruKxY0SY1IfwOgvnirA6M-7w/s1600/free-wallpaper-2.jpg) repeat-x fixed top center;
   -moz-background-size:100%;
   -webkit-background-size:100%;
   -o-background-size:100%;
   background-size:100%;
}

Jika sudah terpasang juga, kita harus menambah JavaScript Backround Slide Show di bawah ini:
<script type='text/javascript'>
var ssBG={
gbr:[
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiczCbZeJpMYup1UH0L5sXF7MP9w9dsqrnTQlqELtJyPFpWdW6PIU6Io8Cmry3LuRWMqJ6AMDLksJX5Vwc3sIDZVHvAKeyHz1str3L8mEyeToutBk29NvCsPrHHLPYvJVl3nMNrD8w5iw/s1600/3d-desktop-background-hd-of-art-and-design.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4vfgmMiGTnQtnE3dRWiXawJj4OPTcR5VGcyMIhDdyJmuu_j1Bdl81K3yQMk2L_NsvxTQkBbEAl0sHDeQYcahRXwc8GCie54rhLtEvRn_FrEV0eLsJASl13iqlwc0OSQ4zPImePtwHuw/s1600/3D-Background-Ball-Free-Download.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVocsz4o6h47dgJ5sVme9fQ7PT3Uls2t0YscPdAnZMZxwjtRbFuRwE-_hhxa9BjkiDFWGErrk1EuDP3Zh05jwDdyycbdBAlNVkQOhtBd25qPSO5AN7DL-4FefQuCE_smRXbQAo1pxW9A/s1600/Snow_leopards.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRE1xrBsc5oOxXEcCnNsY3DJFFHKI7IND5QBzB6yuGTJBR-Q07vcgck1MHLXFJoyIkIg9Hv4p91uUvUCde__d3I9rK-OIQt_Kh2e955JSIeTYk0EOJgL2_hhaRM9sM39ns6GudKc5bdg/s1600/3d-hd-wallpaper-ja-amazing-wallpaper+%281%29.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5hEGwbwT4CA_Xt4zLhQsnAtu25l9JR5Dl9VsYxNKoArZaFTKnuLNWAOmmipedMwxeJO-ZI1uk_lutIRLMPibmBT7fZ6U4dMdNqKEgmKJ-_L6ZnFjaXXCE1V8cjsmRPVFbsxGL7APvxg/s1600/3d-desktop-backgrounds.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrzRLP90PZBppvVfaQ_l_8D_uNeF8Bs5ViMfyptH5gOCA6H3uNEbc7peQV06YiHM2PSXrf2cHhGp0-Cxs2vS7hfIJdcMdIu8FzGFbszOc-MrWCP5u-LHoYD4eDGIDSGS-pc9gEgms3Tw/s1600/3D_desktop_wallpaper.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2gRCZwScEuG2TCWykwljBWbl20pIcOacpiYVR0UkNAJFanykkgbQ6ZxkZ9Ry9__JIA7_i3d0boSedycos9AhYrHYW6W6yrySsxZRTo7XQatSD11Uodngu9Mdg4BUheOcm_SsWSK6n-UU/s1600/China_Country_4+%28wallpapersbay.blogspot.com%29.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUQJk1-rgN98-HK9ytKG7o-VVdRFA0QQfaBUI1J-SomjM6VV6d_NZHB8YKlvuRJR0J4smjDa3fYv62jhzS5R7GpSBmgj0s5xnEyZxONB7EqR5zkSHd6sZVrH4dYOpa2hrYEUq4_zjeykU/s1600/Rainbow_Wallpapers_(1)+%28wallpapersbay.blogspot.com%29.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxVREHRi5WlBEJKedDxXBwUVL8T7-W3bW8KihhipE70HbupK1vnOjUa2iAdjn-rnuB7wKqFeQ_BROZk0VuzYxt9mCghkDc6QxGZ8ITtVi5sfutjcxDi4itW4rxYYFmUChYMMvAspA_f7c/s1600/Creative-Digital-Animal-Wallpapers-24+%28wallpapersbay.blogspot.com%29.jpg",
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtuM93PTDdom-tHP2Ak8TXQmXdcTqjad9SMd2UVxa3YxxRyZr8tnkMX10l9UZNmpWDBH9Z8U7_MOO4DrEt9RuoNYrH3pHVa0ZCM304crawJlpyyYzt7HcMak0HS4jkDViAW9QbfE7C2vQ/s1600/Thunder_Storm_Wallpapers_(37)+%28wallpapersbay.blogspot.com%29.jpg"
],
now:0,
SlideMyBG:function(list,style,speed,bgPos,bgSize,bgRep){
if(!ssBG.SlideMyBG.hasRun){ssBG.SlideMyBG.hasRun=true;
if(list==null||list==''){list=ssBG.gbr}else{if(typeof list!='object'){list=ssBG.gbr}}
if(style==null||style==''){style='random'}
if(speed==null||speed==''){speed=5000}
if(bgPos==null||bgPos==''){bgPos='top center'}
if(bgSize==null||bgSize==''){bgSize='100%'}
if(bgRep==null||bgRep==''){bgRep='repeat'}
ssBG.gaya=style;ssBG.jeda=speed;ssBG.gbr=list;ssBG.pos=bgPos;ssBG.size=bgSize;ssBG.rep=bgRep;
ssBG.opt={'background-attachment':'fixed','background-repeat':ssBG.rep,'-moz-background-size':ssBG.size,'background-size':ssBG.size};
}
if(ssBG.gaya=='random'){ssBG.gbr=ssBG.gbr.sort(function(){return 0.5-Math.random()})}
var img=new Image();var brp=ssBG.gbr.length;if(ssBG.now>=brp){ssBG.now=0}
var gbrSkrng=ssBG.gbr[ssBG.now];ssBG.now++;
if($('#bg-fader').length==0){$('body').prepend('<div id="bg-fader" style="opacity:0.0;top:0;left:0;width:100%;height:100%;background-color:'+$('body').css('background-color')+'"></div>');$('#bg-fader').css(ssBG.opt);$('body').css(ssBG.opt)}
$(img).load(function(){
$('#bg-fader').css({'background-image':'url('+gbrSkrng+')','background-position':ssBG.pos}).animate({opacity:1.0},'slow','linear',function(){
$('body').css({'background-image':'url('+gbrSkrng+')','background-position':ssBG.pos});
$(this).animate({opacity:0.0},'slow','linear');
setTimeout("ssBG.SlideMyBG()",ssBG.jeda);
});
}).attr('src',gbrSkrng).error(function(huh){ssBG.SlideMyBG()});
}
};
</script>

<script type='text/javascript'>$(window).load(function(){ssBG.SlideMyBG()})</script>

Tidak ada komentar:

Posting Komentar

 
;);