Welcome to my blog. Feel free to read my stories and etc. I rarely update this blog. Sixteen.


home. | le owner. | stuff. | affiliates. | flavors. | chatbox.

Khamis, 26 Januari 2012

Shake Image Hover

Click here for more inspiring photos!

Assalamualaikum + Hye

\Bismillahirrahmanirrahim/ Hello fellas ^^ Tadi ade request tuto dari Fadlin. Dia tanye camno nak buat image hover bergegar mcm saye tuh? Hehe btw image hover tu x berfungsi di entry tau, dye cume berfungsi di sidebar dll. Jadi ape tunggu lagi, jom start :D

  • Dashboard > Template
  • Cari kod ni <style type="text/css">
  • Copy kod di bawah dan paste kod tu di atas <style type="text/css">
<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">


/*
Shake image script (onMouseover)-
  Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/


//configure shake degree (where larger # equals greater shake)
var rector=3

///////DONE EDITTING///////////
var stopit=0
var a=1

function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}


function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector+"px"
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector+"px"
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector+"px"
}
else{
shake.style.left=parseInt(shake.style.left)-rector+"px"
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}

function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}

</script>

Jangan save dulu! Belum habis lagi. Bikin tensyen je =,=


  • Dashboard > Template
  • Copy kod di bawah dan paste di gambar yang korang nak
<img src="REPLACE_IMAGE_URL_HERE" class="shakeimage" onMouseover="init(this);rattleimage()"
onMouseout="stoprattle(this);top.focus()" onClick="top.focus()">

Contoh koding saya :

<img src="http://data.whicdn.com/images/21806203/tumblr_lxy5grEWOR1r5z2n4o1_400_large.jpg" class="shakeimage" onMouseover="init(this);rattleimage()" onMouseout="stoprattle(this);top.focus()" onClick="top.focus() width="300"/> 

Jadi kepada korang x tau camne nak cari URL image klik sini eh. Tapi tutorialnye bahasa inggeris, korang paham2 jelah kay. Thanks to Tumblr for this tutorial :D

Assalamualaikum. Peace yoo.

2 ulasan:

Muhd Fadlin berkata...

wahh, thanks thanks ;)

Nurul Nurfarahin berkata...

hehe, wlcm :)