Rabu, 16 Februari 2011

membuat menu jQuery fixed navigation






Contohnya bisa dilihat disini
* Login ke blogger
* Masuk ke rancangan dan pilih Edit HTML
* Copy kode jQuery dibawah ini sebelum atau diatas kode <head>

<link charset='utf-8' href='https://sites.google.com/site/jayanaktkj/fixedmenu/style.css' rel='stylesheet' type='text/css'/>
<script type='text/javascript'>

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-7243260-2&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

* Terakhir cari kode <body> dan letakkan kode dibawah ini sebelum atau diatas kode <body> ini kodenya:

<div class='header'/>
        <ul id='navigation'>
            <li class='home'><a href='alamat url'><span>Beranda</span></a></li>
            <li class='about'><a href='http://www.blogger.com/profile/10996701309860975254'><span>Tentang</span></a></li>
            <li class='search'><a href='alamat url'><span>Cari</span></a></li>
            <li class='photos'><a href='alamat url'><span>Foto</span></a></li>

            <li class='rssfeed'><a href='alamat url'><span>Rss Feed</span></a></li>
            <li class='podcasts'><a href='alamat url'><span>Podcasts</span></a></li>
            <li class='contact'><a href='alamat url'><span>Kontak</span></a></li>
        </ul>
<script src='http://tympanus.net/Tutorials/FixedNavigationTutorial2/jquery-1.3.2.js' type='text/javascript'/>
        <script type='text/javascript'>
            $(function() {
                var d=300;
                $(&#39;#navigation a&#39;).each(function(){
                    $(this).stop().animate({
                        &#39;marginTop&#39;:&#39;-80px&#39;
                    },d+=150);
                });

                $(&#39;#navigation &gt; li&#39;).hover(
                function () {
                    $(&#39;a&#39;,$(this)).stop().animate({
                        &#39;marginTop&#39;:&#39;-2px&#39;
                    },200);
                },
                function () {
                    $(&#39;a&#39;,$(this)).stop().animate({
                        &#39;marginTop&#39;:&#39;-80px&#39;
                    },200);
                }
            );
            });
        </script>

* Ganti alamat url dengan alamat url kalian masing

Tidak ada komentar:

Posting Komentar