Domanda

I am a noob, but I am trying to build this navigation bar that is fixed to the top that has a smooth easing effect over it. I found one that has worked for me but the whole nav box doesn't click. you have to hover over the word to navigate to the next page. here is my code:

(function($) {

$.fn.spasticNav = function(options) {

    options = $.extend({
        overlap : 20,
        speed : 500,
        reset : 1500,
        color : '#0b2b61',
        easing : 'easeOutExpo'
    }, options);

    return this.each(function() {

        var nav = $(this),
            currentPageItem = $('#selected', nav),
            blob,
            reset;

        $('<li. id="blob"></li>').css({
            width : currentPageItem.outerWidth(),
            height : currentPageItem.outerHeight() + options.overlap,
            left : currentPageItem.position().left,
            top : currentPageItem.position().top - options.overlap / 2,
            backgroundColor : options.color
        }).appendTo(this);

        blob = $('#blob', nav);

        $('li:not(#blob)', nav).hover(function() {
            // mouse over
            clearTimeout(reset);
            blob.animate(
                {
                    left : $(this).position().left,
                    width : $(this).width()
                },
                {
                    duration : options.speed,
                    easing : options.easing,
                    queue : false
                }
            );
        }, function() {
            // mouse out    
            reset = setTimeout(function() {
                blob.animate({
                    width : currentPageItem.outerWidth(),
                    left : currentPageItem.position().left
                }, options.speed)
            }, options.reset);

        });

    }); // end each

};

})(jQuery);

Now I have been looking everywhere and I was able to find the code that will do it but i have no idea where to put it. Bellow is the code: this youtube video does exactly what I want to do: youtu( .)be/kzRwMRwKb6o

$("NotSureWhat to put in here").click(function(){ window.location=$(this).find("a").attr("href");return false; });

Please any help will be greatly appreciated.

OK here is a jfiddle but it doesn't seem to be working properly: http://jsfiddle.net/GoodVibeDJs/D2kZw/

ps. here is what the nav looks like except mine is fixed.

http://mauryacravings.com/labs/components/menu/menu_44/JeffreyWay-SpasticNav-68832b9/

È stato utile?

Soluzione

Besides the fact that a lot needs to be fixed, follow the instructions below.

Add this to your #nav li a

padding: 13px 25px 0;
box-sizing: border-box;
height:100%;

and remove padding-right:50px & top:13px

http://jsfiddle.net/D2kZw/1/

Altri suggerimenti

WHY USING JS? you can do this only with css, here an fiddle http://jsfiddle.net/6XEMc/5/

HTML

<nav>
    <li class="it"><a href="#">ITEM 01</a></li>
    <li class="it"><a href="#">ITEM 02</a></li>
    <li class="it"><a href="#">ITEM 03</a></li>
    <li class="it"><a href="#">ITEM 04</a></li>
    <li class="it"><a href="#">ITEM 05</a></li>
    <li class="it"><a href="#">ITEM 06</a></li>
    <li class="it"><a href="#">ITEM 07</a></li>
    <li class="it"><a href="#">ITEM 08</a></li>
    <li class="it"><a href="#">ITEM 09</a></li>
    <li class="it"><a href="#">ITEM 10</a></li>
</nav> 
<p>&nbsp; 01</p>
<p>&nbsp; 02</p>
<p>&nbsp; 03</p>
<p>&nbsp; 04</p>
<p>&nbsp; 05</p>
<p>&nbsp; 06</p>
<p>&nbsp; 07</p>
<p>&nbsp; 08</p>
<p>&nbsp; 09</p>
<p>&nbsp; 10</p>
<p>&nbsp; 11</p>
<p>&nbsp; 12</p>
<p>&nbsp; 13</p>
<p>&nbsp; 14</p>
<p>&nbsp; 15</p>
<p>&nbsp; 16</p>
<p>&nbsp; 17</p>
<p>&nbsp; 18</p>
<p>&nbsp; 19</p>
<p>&nbsp; 20</p>
<p>&nbsp; 21</p>
<p>&nbsp; 22</p>
<p>&nbsp; 23</p>
<p>&nbsp; 24</p>
<p>&nbsp; 25</p>
<p>&nbsp; 26</p>
<p>&nbsp; 27</p>
<p>&nbsp; 28</p>
<p>&nbsp; 29</p>
<p>&nbsp; 30</p>
<p>&nbsp; 31</p>
<p>&nbsp; 32</p>
<p>&nbsp; 33</p>
<p>&nbsp; 34</p>
<p>&nbsp; 35</p>
<p>&nbsp; 36</p>
<p>&nbsp; 37</p>
<p>&nbsp; 38</p>
<p>&nbsp; 39</p>
<p>&nbsp; 40</p>
<p>&nbsp; 41</p>
<p>&nbsp; 42</p>
<p>&nbsp; 43</p>
<p>&nbsp; 44</p>
<p>&nbsp; 45</p>
<p>&nbsp; 46</p>
<p>&nbsp; 47</p>
<p>&nbsp; 48</p>
<p>&nbsp; 49</p>
<p>&nbsp; 50</p>
<p>&nbsp; 51</p>
<p>&nbsp; 52</p>
<p>&nbsp; 53</p>
<p>&nbsp; 54</p>
<p>&nbsp; 55</p>
<p>&nbsp; 56</p>
<p>&nbsp; 57</p>
<p>&nbsp; 58</p>
<p>&nbsp; 59</p>
<p>&nbsp; 60</p>
<p>&nbsp; 61</p>
<p>&nbsp; 62</p>
<p>&nbsp; 63</p>
<p>&nbsp; 64</p>
<p>&nbsp; 65</p>
<p>&nbsp; 66</p>
<p>&nbsp; 67</p>
<p>&nbsp; 68</p>
<p>&nbsp; 69</p>
<p>&nbsp; 70</p>
<p>&nbsp; 71</p>
<p>&nbsp; 72</p>
<p>&nbsp; 73</p>
<p>&nbsp; 74</p>
<p>&nbsp; 75</p>
<p>&nbsp; 76</p>
<p>&nbsp; 77</p>
<p>&nbsp; 78</p>
<p>&nbsp; 79</p>
<p>&nbsp; 80</p>
<p>&nbsp; 81</p>
<p>&nbsp; 82</p>
<p>&nbsp; 83</p>
<p>&nbsp; 84</p>
<p>&nbsp; 85</p>
<p>&nbsp; 86</p>
<p>&nbsp; 87</p>
<p>&nbsp; 88</p>
<p>&nbsp; 89</p>
<p>&nbsp; 90</p>
<p>&nbsp; 91</p>
<p>&nbsp; 92</p>
<p>&nbsp; 93</p>
<p>&nbsp; 94</p>
<p>&nbsp; 95</p>
<p>&nbsp; 96</p>
<p>&nbsp; 97</p>
<p>&nbsp; 98</p>
<p>&nbsp; 99</p>
<p>&nbsp; 100</p>

CSS

* {
    margin: 0;
    padding: 0;
}

body {
    background: url(http://wallpoper.com/images/00/44/48/44/blurred-grass_00444844.jpg) center fixed;
}

nav {
    position: fixed;
    top: 0;
    left: 0;
}

nav li {
    list-style: none;
    display: block;
    width: 150px;
}

nav li a {
    width: 100%;
    padding: 10px;
    display: block;
    text-align: right;
    background: #963;
    background: rgba(153, 102, 51, 0.9);
    text-decoration: none;
    color: #FFF;
    border-bottom: 1px solid #80552A;
}

nav li:hover {
    width: 300px;
}

nav li {
    -webkit-transition: all .5s ease-in-out;
    -moz-transition: all .5s ease-in-out;
    -ms-transition: all .5s ease-in-out;
    -o-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top