Membuat slide show post di blog
Halooo teman-teman, kali ini saya akan membahas (walau kenyataanya sama-sama belajar) tentang cara membuat slideshow tentang post kita di blog. Dengan adanya slideshow, pengunjung akan dimudahkan untuk melihat "keseluruhan" dari isi blog kita sekaligus mempercantik tampilan dari blog kita sendiri, tetapi di tutorial ini saya menggunakan interface lama, jadi bagi pemula yang menggunakan interface baru diharap menyesuaikan, kalau perlu diubah ke interface lama.Pertama-tama, masuk ke dasbor blog kita, dan klik "rancangan". Setelah masuk tab rancangan, klik "edit html" dan masukkan kode berikut ini di bawah persis kode <head> (kalau teman-teman kesulitan mencari kode <head> gunakan find [ctrl+F]). Jangan lupa di centang Expand template widget yaa. Berikut ini kodenya:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
//Execute the slideShow, set 6 seconds for each images
slideShow(3000);
});
function slideShow(speed) {
//append a LI item to the UL list for displaying caption
$('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');
//Set the opacity of all images to 0
$('ul.slideshow li').css({opacity: 0.0});
//Get the first image and display it (set it to full opacity)
$('ul.slideshow li:first').css({opacity: 1.0});
//Get the caption of the first image from REL attribute and display it
$('#slideshow-caption h3').html($('ul.slideshow a:first').find('img').attr('title'));
$('#slideshow-caption p').html($('ul.slideshow a:first').find('img').attr('alt'));
//Display the caption
$('#slideshow-caption').css({opacity: 0.7, bottom:0});
//Call the gallery function to run the slideshow
var timer = setInterval('gallery()',speed);
//pause the slideshow on mouse over
$('ul.slideshow').hover(
function () {
clearInterval(timer);
},
function () {
timer = setInterval('gallery()',speed);
}
);
}
function gallery() {
//if no IMGs have the show class, grab the first image
var current = ($('ul.slideshow li.show')? $('ul.slideshow li.show') : $('#ul.slideshow li:first'));
//Get next image, if it reached the end of the slideshow, rotate it back to the first image
var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
//Get next image caption
var title = next.find('img').attr('title');
var desc = next.find('img').attr('alt');
//Set the fade in effect for the next image, show class has higher z-index
next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
//Hide the caption first, and then set and display the caption
$('#slideshow-caption').animate({bottom:-70}, 300, function () {
//Display the content
$('#slideshow-caption h3').html(title);
$('#slideshow-caption p').html(desc);
$('#slideshow-caption').animate({bottom:0}, 500);
});
//Hide the current image
current.animate({opacity: 0.0}, 1000).removeClass('show');
}
//]]>
</script>
<style type='text/css'>
ul.slideshow {
list-style:none;
width:600px;
height:240px;
overflow:hidden;
position:relative;
margin:0;
padding:0;
font-family:Arial,Helvetica,Trebuchet MS,Verdana;
;
}
ul.slideshow li {
position:absolute;
left:0;
right:0;
}
ul.slideshow li.show {
z-index:500;
}
ul img {
width:600px;
height:240px;
border:none;
}
#slideshow-caption {
width:600px;
height:70px;
position:absolute;
bottom:0;
left:0;
color:#fff;
background:#000;
z-index:500;
}
#slideshow-caption .slideshow-caption-container {
padding:5px 10px;
z-index:1000;
}
#slideshow-caption h3 {
margin:0;
padding:0;
font-size:16px;
}
#slideshow-caption p {
margin:5px 0 0 0;
padding:0;
}
</style>
Nb: yang berwarna merah dapat diganti sesuai keinginan teman teman untuk menyesuaikan ukuran.
Apakah dengan ini gambar sudah tampil? Sabar ya teman-teman, BELUM, hahaha. Masih ada 1 langkah lagi nih, masih di menu rancangan, klik "elemen laman" dan klik lagi "tambah gadget". nah, di sana ada banyak pilihan gadget kan? pilih yang HTML/Java Script dan masukkan kode berikut ini:
<ul class="slideshow">
<li><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjELR2zckybw69_4l4t9H2AScGJjfo5TcqokWhb6alk2sjCSp7udRmpZZDSTHoNGzQ_vZGKRz8U-mlLVlDOt8b_bbfeP1yWGACGoZektA5YEbo54lB2WbgpAtphKBJM-eoQc2qDDcPWKw/s1600/1.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjELR2zckybw69_4l4t9H2AScGJjfo5TcqokWhb6alk2sjCSp7udRmpZZDSTHoNGzQ_vZGKRz8U-mlLVlDOt8b_bbfeP1yWGACGoZektA5YEbo54lB2WbgpAtphKBJM-eoQc2qDDcPWKw/s1600/1.jpg" title="This is featured post 1 title" alt="Replace This Text With Your Featured Post 1 Description." /></a></li>
<li><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN2RtqK9HyVDqTTarit-5D2p7c9dlMXaZ2ewfe73DRji69_2ZPYTGhGSWv7cLx7eW-BU-Stm7dFvuHeJ_QVWb7qaWBhbXv9-AkrGEGlbIyQILcwSxwxX1Y5ggXLho-9sBm5Lnyg0OlQYA/s1600/2.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN2RtqK9HyVDqTTarit-5D2p7c9dlMXaZ2ewfe73DRji69_2ZPYTGhGSWv7cLx7eW-BU-Stm7dFvuHeJ_QVWb7qaWBhbXv9-AkrGEGlbIyQILcwSxwxX1Y5ggXLho-9sBm5Lnyg0OlQYA/s1600/2.jpg" title="This is featured post 2 title" alt="Replace This Text With Your Featured Post 2 Description." /></a></li>
<li><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3kO8SdMctHLxnHHN9krAA-FXRWkAWccKD2df4UGpbA7JrcOQhb-ZyAqOUCsdnJa1_Jajdjaf-f9Wp9wDl3y3NxyxJCRg1tdjGb0WUAtoTgvu49KGYWxJkFiPRPL42IL-fJB225yHS5NM/s1600/3.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3kO8SdMctHLxnHHN9krAA-FXRWkAWccKD2df4UGpbA7JrcOQhb-ZyAqOUCsdnJa1_Jajdjaf-f9Wp9wDl3y3NxyxJCRg1tdjGb0WUAtoTgvu49KGYWxJkFiPRPL42IL-fJB225yHS5NM/s1600/3.jpg" title="This is featured post 3 title" alt="Replace This Text With Your Featured Post 3 Description." /></a></li>
<li><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjidUX4_aXGVNs-ErqRJTrfqNYIDBAuptnp3VOToRZT5vOhIW3l_ZHSFP5Vp9wFHBGMJp6em5VxMTahaQXxE1c1HbvNFIpmePE8_7GA1wLUuzPPMQX-NR1mm6D24u8ccWgInA1160nFrSk/s1600/4.jpg"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjidUX4_aXGVNs-ErqRJTrfqNYIDBAuptnp3VOToRZT5vOhIW3l_ZHSFP5Vp9wFHBGMJp6em5VxMTahaQXxE1c1HbvNFIpmePE8_7GA1wLUuzPPMQX-NR1mm6D24u8ccWgInA1160nFrSk/s1600/4.jpg" title="This is featured post 4 title" alt="Replace This Text With Your Featured Post 4 Description." /></a></li>
</ul>
Nb: yang saya beri warna bisa teman-teman ganti sesuai keinginan teman teman, cari tau sendiri ya, kalo nggak comment di bawah :D
oke, kalau berhasil akan tampak slide show di Home blog teman-teman. Yang masih gagal, jangan menyerah!!! Coba terus sampai bisa, Semangat!!! hahaha....
cukup sekian post dari saya, takut kepanjangan, hehehe
terima kasih
sumber code: http://pelajaran-blog.blogspot.com/2012/01/membuat-slideshow-photo-foto-berubah.html
0 comments: