Sabtu, 05 April 2014

Cara Membuat Background Bergerak di Blog


Info unik kali ini mengenai salah satu trik membuat gambar background blog menjadi dinamis. Trik ini menggunakan JQuery sederhana yang dikhususkan untuk membuat gambar background menjadi bergerak (Scrolling Background). Script ini membuat gambar background blog bergerak secara vertikal dari arah bawah ke arah atas. Buat sobat blogger yang ingin mencobanya silakan disimak trik membuat scrolling background berikut ini.



  • Login » blogger.
  • Rancangan » Edit HTML.
  • Apabila anda belum menggunakan kode JQuery silakan anda pasang kode JQuery dibawah ini tepat di atas Kode </Head>.

    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=1.3.2' type='text/javascript'></script>

  • Copy-Paste kode di bawah ini tepat di atas Kode </Head>.

    <script type='text/javascript'>
    //<![CDATA[
    $(function(){
    // ***
    // Scrolling background
    // ***
    // height of background image in pixels
    var backgroundheight = 4000;

    // get the current minute/hour of the day
    var now = new Date();
    var hour = now.getHours();
    var minute = now.getMinutes();

    // work out how far through the day we are as a percentage - e.g. 6pm = 75%
    var hourpercent = hour / 24 * 100;
    var minutepercent = minute / 30 / 24 * 100;
    var percentofday = Math.round(hourpercent + minutepercent);

    // calculate which pixel row to start graphic from based on how far through the day we are
    var offset = backgroundheight / 100 * percentofday;

    // graphic starts at approx 6am, so adjust offset by 1/4
    var offset = offset - (backgroundheight / 1);

    function scrollbackground() {
    // decrease the offset by 1, or if its less than 1 increase it by the background height minus 1
    offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
    // apply the background position
    $('body').css("background-position", "50% " + offset + "px");
    // call self to continue animation
    setTimeout(function() {
    scrollbackground();
    }, 70
    );
    }
    // Start the animation
    scrollbackground();
    });

    //]]>
    </script>
  • Copy-Paste Kode CSS di bawah ini tepat di atas Kode </Head> untuk memasang gambar background. Anda dapat mengganti gambar background sesuai dengan yang anda inginkan dengan merubah alamat hosting gambar pada Kode CSS di bawah dengan alamat hosting gambar yang anda pilih.

    <style>
    body {
    background: black url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQrFGcQLO5mUuqQPH9E2BX6P-4CAwtUi6hV0UC5fc7VPIfvtiZoK9IDV4S3qOMyyGWxCtcEVjAKFRSEFGSjerppC4MWmSXf1nBypfYZPRgYqYEC-cxnyFeHIlD6OakK7e1jGe59zy3363v/s800/bg.gifrepeat center; background-attachment: fixed;
    }
    </style>

  • Keterangan :
    repeat // Pengulangan gambar arah x dan y.
    • repeat-x // Pengulangan gambar hanya arah horizontal.
    • repeat-y // Pengulangan gambar hanya arah vertikal.
    - http://3.bp.blogspot.com/-tS5lZKl3Qag/TtjQUfMzi2I/AAAAAAAAAkA/QZc2FwvhW4o/s200/bg.gif // URL Link gambar.
    - center // Lokasi gambar berada di tengah layar.
    • Left // Lokasi gambar berada di kiri gambar.
    • Right // Lokasi gambar berada di kanan gambar.

Pilihan Gambar Background 


  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQrFGcQLO5mUuqQPH9E2BX6P-4CAwtUi6hV0UC5fc7VPIfvtiZoK9IDV4S3qOMyyGWxCtcEVjAKFRSEFGSjerppC4MWmSXf1nBypfYZPRgYqYEC-cxnyFeHIlD6OakK7e1jGe59zy3363v/s800/bg.gif



  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHjYDKh9bKy08Bi_TcdwrfukzkLGrfusCOAFyI1E8akOkt7OP3mEoKIf9qYktlzyGbtdWYflvMjR9bcp55ZfcCMk_eGQXFa914lUXljmEX0_-x1glHs5C4VUsQxR-B6zE7qo0P5QoGm0ou/s800/bg_star.png

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYo2mtyZOj4z4-h533B1q4MuLSsEjM9n0u_4f2piJ5vABiFvAPGCUlkE1yihKL05ApxKG82hnYO3DJc2DKCHD6lnu8wdwUkdmTyTIniKjh8ujkrnUFqNKq0wFYUFKTyT3dUqZZTT3aYOPm/s800/bg-clouds.jpg

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZhFulPlZg_ygTObO7_CTAj7qORCFxnZPvIRQiKXPveoDkC9F6DoBPvYryzwfMZw1HeK3KtDJbFdTg2-Ojfm5hFK98b-3CyZiXPtLbBGYvH4-jk52mY-NSkXxjsY6aPZ0dBvO4AtN_zhSA/s800/skull-fire-monozcore.png

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3RpKCcrfUwXliL-VRs7EDAaIYGqj3uYrp5MibcS7W8_2V2rEE3NbdySBfAH-l40djXQXO7-D7FRASyPYqEv1GTMxhJ_oWMzvBPTPFy2_wGZZO2Xp5fy_gdrcAWGDfv0quhDCnwIkjKMmK/s800/dance_flow.png

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii74E7t7WPsQwUtKgH4K39nOdAbhpq-aT5EYOefCYsA5Oljev5rZ2-kMafMcm2cMh3T55QJY6wtDjnGgRzPTunUq0UT6jWX9pEvZAOuCDQihCH6DObdxwbkAXASJ2X3KjISDU5PsYYlK25/s800/ThighHeels.png

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4RHVeHx7Jom6KHO8jtVxY3-hvKOHYHhAWHoQjbE9uI65Y30YFjC1dedMqNOYjAecQsDW500A_dbi4S5t8SXjiUbQ9-sfX_QDz14ZJvMVsn3RE23U40ovo6t592Tdh0QDI6dF23It9GO8Q/s800/animated%2520stars.gif

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMKVa4TxeMrWwuaNJhO-cz9jzkG7sGr6ktlkjFgn1HytJqHoYEuVpYqJmd0THBBlgYMGFdZp0hQFpWm2ESeDCEz1OWc37_9PY6-4XOjQzR0ZUfaFzUsdyxRE8P2EfxP6TIaZ2zM8oPM11_/s800/animated%2520blue%2520stars.gif

  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_7u8mHDqE1pPsvCjjyHZqIHjhXGqjBddMSoNkgv6myYorgA__5uI4WfK38Q2j78s5_xbHRTByDH1oOp731TvItJa0q9zPRYj3VBeSmuObeh8_3vLPaL5OARqZdSSxOFCND-KxC9YRzzti/s800/devil_angel_lolita_bg.png
.:Selamat Mencoba:.

Tidak ada komentar: