cara membuat gallery foto dengan jQuery

on Wednesday, July 21, 2010
how images gallery with jQuery hover

coba lihat demo disini. untuk membuat nya, Go to you're blogger dashbor | Desain | edit HTML, find code ]]></b:skin> lalu letakan code css dibawah ini sebelum code ]]></b:skin>

/* Gallery
---------------------------------------------- */
ul.thumb {
float: left;
list-style: none;
margin: 0; padding: 10px;
width: 360px;
}
ul.thumb li {
margin: 0; padding: 1px;
float: left;
position: relative; /* Set the absolute positioning base coordinate */
width: 110px;
height: 110px;
}
ul.thumb li img {
width: 100px; height: 100px; /* Set the small thumbnail size */
-ms-interpolation-mode: bicubic; /* IE Fix for Bicubic Scaling */
border: 1px solid #ddd;
padding: 1px;
background: transparent;
position: absolute;
left: 0; top: 0;
}
ul.thumb li img.hover {
background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI1F9xweMrTVZVmhfjnuxSwya4mgjqsxdsNAi4F2oFYRJcR7nwudsOz3mCrlnWf1Mx01kLZimWNy9Iel9p5s-UFdgOVHWknNY-F9LTVKZNQq27on2LolmQc4E0EO54_zXtrcdxqbBsQAp0/) no-repeat center center; /* Image used as background on hover effect
border: none; /* Get rid of border on hover */
}

lalu cari tag </head>
letakan code script diatas tag

<script src='http://code.jquery.com/jquery-latest.js'
type='text/javascript'/>
<script type='text/javascript'>
$(document).ready(function(){

//Larger thumbnail preview

$(&quot;ul.thumb li&quot;).hover(function() {
$(this).css({&#39;z-index&#39; : &#39;10&#39;});
$(this).find(&#39;img&#39;).addClass(&quot;hover&quot;).stop()
.animate({
marginTop: &#39;-110px&#39;,
marginLeft: &#39;-110px&#39;,
top: &#39;50%&#39;,
left: &#39;50%&#39;,
width: &#39;174px&#39;,
height: &#39;174px&#39;,
padding: &#39;20px&#39;
}, 200);

} , function() {
$(this).css({&#39;z-index&#39; : &#39;0&#39;});
$(this).find(&#39;img&#39;).removeClass(&quot;hover&quot;).stop()
.animate({
marginTop: &#39;0&#39;,
marginLeft: &#39;0&#39;,
top: &#39;0&#39;,
left: &#39;0&#39;,
width: &#39;100px&#39;,
height: &#39;100px&#39;,
padding: &#39;5px&#39;
}, 400);
});

//Swap Image on Click
$(&quot;ul.thumb li a&quot;).click(function() {

var mainImage = $(this).attr(&quot;href&quot;); //Find Image Name
$(&quot;#main_view img&quot;).attr({ src: mainImage });
return false;
});

});
</script>

lalu simpan.

untuk selanjutnya, anda bisa menentukan letak penempatan HTML dibawah ini, bisa di post, sidebar, atau lain-lain. tergantung dari anda memilih tempat untuk meletakan code. berikut:

<ul class="thumb">
<li><a href="#"><img src="picture 1 Link" alt="" /></a></li>
<li><a href="#"><img src="picture 2 Link" alt="" /></a></li>
<li><a href="#"><img src="picture 3 Link" alt="" /></a></li>
<li><a href="#"><img src="picture 4 Link" alt="" /></a></li>
</ul>

keterangan :

tambahkan code yang sama untuk jumlah yang anda tentukan.

<li><a href="#"><img src="picture Link" alt="" /></a></li>

lalu, smile... :)

1 comments:

atanotonogoro said...

makasih ya infonya :)

Post a Comment