Laman


ShoutMix chat widget

Sabtu, 25 Juni 2011

Cara Membuat Gambar Mengikuti Cursor

Sekedar variasi dalam menampilkan image pada blog, tips ini merupakan cara menampilkan image yang apabila disorot oleh mouse, kemudian digeserkan/drag, maka image tersebut akan bergerak mengikuti arah mouse.
Mungkin trik ini tidak terlalu penting untuk ditampilkan pada blog. Tapi tidak ada salahnya kalau dicoba untuk tampil pada blog anda, sekedar variasi dari tampilan gambar yang mungkin dapat menarik minat tamu blog anda untuk memindahkan gambar tersebut.

LANGKAH PERTAMA
  1. Masuk ke Blogger dengan ID anda
  2. Masuk Rancangan
  3. Pilih Edit HTML
  4. Cari kode </head> pada template anda
  5. Copy kode dibawah ini, kemudian paste tepat diatas kode tadi


    <style type="text/css">
    .drag{
    position:relative;
    cursor:hand;
    z-index: 100;
    }
    </style>
    <script type="text/javascript">
    var dragobject={
    z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
    initialize:function(){
    document.onmousedown=this.drag
    document.onmouseup=function(){this.dragapproved=0}
    },
    drag:function(e){
    var evtobj=window.event? window.event : e
    this.targetobj=window.event? event.srcElement : e.target
    if (this.targetobj.className=="drag"){
    this.dragapproved=1
    if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
    if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
    this.offsetx=parseInt(this.targetobj.style.left)
    this.offsety=parseInt(this.targetobj.style.top)
    this.x=evtobj.clientX
    this.y=evtobj.clientY
    if (evtobj.preventDefault)
    evtobj.preventDefault()
    document.onmousemove=dragobject.moveit
    }
    },
    moveit:function(e){
    var evtobj=window.event? window.event : e
    if (this.dragapproved==1){
    this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
    this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
    return false
    }
    }
    }
    dragobject.initialize()
    </script>;
  6. Klik Simpan Template
LANGKAH KEDUA
  • Langkah kedua ini bisa anda terapkan pada postingan maupun pada elemen halaman
  • Tambahkan kode class="drag" pada alamat gambar
  • Perhatikan contoh dibawah ini (perhatikan yang berwarna merah).
    <img src="http://img52.imageshack.us/img52/3915/36261.gif" class="drag"/>

6 komentar:

  1. I аm in fаct delіghted to glance at this wеblog posts whіch carries tons οf
    valuable facts, thanks for proviԁing thesе
    kinds of infoгmatiοn.

    My web-site; samsung galaxy note 2
    My website

    BalasHapus
  2. What's up colleagues, its fantastic post about teachingand completely explained, keep it up all the time.

    Also visit my weblog - pikavippi
    My site - pikavippi

    BalasHapus
  3. I want to to thank yοu foг this fantаstic read!
    ! I ԁefinіtely enjοyеd evеry little bit οf it.
    I've got you saved as a favorite to look at new things you post…

    Also visit my webpage; dgh
    Here is my webpage ... gfe

    BalasHapus
  4. It's appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I desire to suggest you few interesting things or suggestions. Maybe you can write next articles referring to this article. I wish to read more things about it!

    My weblog - zulutradeonline.com
    Feel free to visit my web-site - зулу трейд форум

    BalasHapus
  5. Fοr the reaѕon that thе admin of this wеb
    site іs woгkіng, no doubt veгy гаpidly іt will be famοuѕ, duе to its quаlity cοntеntѕ.


    Mу blog pοst - pikavippi
    Also visit my web page ... pikavippi

    BalasHapus
  6. I'll immediately grasp your rss as I can not to find your email subscription link or e-newsletter service. Do you've any?

    Kindly permit me recognise so that I may just subscribe.
    Thanks.

    My web site ... zulutradeonline

    BalasHapus

Boleh komentar,,,dilarang spam..

Cara Membuat Gambar Mengikuti Cursor | Info Indie