Heim >Web-Frontend >js-Tutorial >jQuery CSS implementiert den Seitennavigationseffekt von Baidu Encyclopedia_jquery

jQuery CSS implementiert den Seitennavigationseffekt von Baidu Encyclopedia_jquery

WBOY
WBOYOriginal
2016-05-16 16:26:191370Durchsuche

Ich habe diese Woche zufällig den Seitennavigationseffekt der Baidu-Enzyklopädie gesehen und fand ihn ziemlich gut, also habe ich mir am Wochenende die Zeit genommen, darüber zu schreiben.

Das Bild unten ist die Darstellung des Navigationsteils:

Das CSS und die Bilder werden von Baidu kopiert und können von der Baidu-Enzyklopädie heruntergeladen werden.

Der spezifische Code lautet wie folgt:

Code kopieren Der Code lautet wie folgt:




   
   
   
   




   


       
        1
        part1
   

   


        content1,content1
       

























   

   


       
        2
        part2
   

   


        content2,content2
       

























   

   


       
        2-1
        part2-1
   

   


        content2-1,content2-1
       

























   

   


       
        2-2
        part2-2
   

   


        content2-2,content2-2
       

























   

   


       
        3
        part3
   

   


        content,content
       

























   

   


       
        4
        part4
   

   


        content,content
       

























   

   


       
        5
        part5
   

   


        content5,content5
       

























   

   


       
        6
        part6
   

   


        content6,content6
       

























   

   


       
        7
        part7
   

   


        content7,content7
       

























   

   


       
        8
        part8
   

   


        content8,content8
       

























   

   


       
        9
        part9
   

   


        content9,content9
       

























   

   


       
        10
        part10
   

   


        content10,content10
       

























   

   


       
        11
        part11
   

   


        content11,content11
       

























   

   


       
        12
        part12
   

   


        content12,content12
       

























   

   


       
        13
        part13
   

   


        content13,content13
       

























   

   


       
        14
        part14
   

   


        content14,content14
       

























   

   


       
        15
        part15
   

   


        content15,content15
       

























       

























        bottom
   



   

       

           

               

               

           

           

               

               

           

           

               

                   

                        1
                        part1
                       
                   

                   

                        2
                        part2
                       
                   

                   

                        2-1
                        part2-1
                       
                   

                   

                        2-2
                        part2-2
                       
                   

                   

                        3
                        part3
                       
                   

                   

                        4
                        part4
                       
                   

                   

                        5
                        part5
                       
                   

                   

                        6
                        part6
                       
                   

                   

                        7
                        part7
                       
                   

                   

                        8
                        part8
                       
                   

                   

                        9
                        part9
                       
                   

                   

                        10
                        part10
                       
                   

                   

                        11
                        part11
                       
                   

                   

                        12
                        part12
                       
                   

                   

                        13
                        part13
                       
                   

                   

                        14
                        part14
                       
                   

                   

                        15
                        part15
                       
                   

               

           

       

       
       
   




<script><br>     var slideInnerHeight = $('#sideCatalog-catalog dl').height();<br>     var slideOutHeight = $('#sideCatalog-catalog').height();<br>     var enableTop = slideInnerHeight - slideOutHeight;<br>     var step = 50;<br>     //点击向上的按钮<br>     $('#sideCatalog-down').bind('click', function () {<br>         if ($(this).hasClass('sideCatalog-down-enable')) {<br>             if ((enableTop - Math.abs(parseInt($('#sideCatalog-catalog dl').css('top')))) > Schritt) {<br>                 $('#sideCatalog-catalog dl').stop().animate({'top': '-=' step}, 'fast');<br>                 $('#sideCatalog-up').removeClass('sideCatalog-up-disable').addClass('sideCatalog-up-enable');<br>             } sonst {<br>                 $('#sideCatalog-catalog dl').stop().animate({'top': -enableTop}, 'fast');<br>                 $(this).removeClass('sideCatalog-down-enable').addClass('sideCatalog-down-disable');<br>             }<br>         } sonst {<br>             return false;<br>         }<br>     })<br>     //点击向下的按钮<br>     $('#sideCatalog-up').bind('click', function () {<br>         if ($(this).hasClass('sideCatalog-up-enable')) {<br>             if (Math.abs(parseInt($('#sideCatalog-catalog dl').css('top'))) > step) {<br>                 $('#sideCatalog-catalog dl').stop().animate({'top': ' =' step}, 'fast');<br>                 $('#sideCatalog-down').removeClass('sideCatalog-down-disable').addClass('sideCatalog-down-enable');<br>             } sonst {<br>                 $('#sideCatalog-catalog dl').stop().animate({'top': '0'}, 'fast');<br>                 $(this).removeClass('sideCatalog-up-enable').addClass('sideCatalog-up-disable');<br>             }<br>         } sonst {<br>             return false;<br>         }<br>     })</p> <p>    //点击导航中的各个目录<br>     $('#sideCatalog-catalog dl').delegate('dd', 'click', function (e) {<br>         var index = $(this).index();<br>         scrollSlide($(this), index);<br>         var ddId = $(this).find('a').stop().attr('href').substring(1);<br>         var windowTop = $('a[name="' ddId '"]').offset().top;<br>         $('body,html').animate({scrollTop: windowTop}, 'fast');<br>         $(this).addClass('heightlight').siblings('dd').removeClass('heightlight');<br>     })</p> <p> //Scrollen Sie durch die Seite, d. h. scrollen Sie mit der Bildlaufleiste<br> $(document).scroll(function () {<br>         var len = $('.headline-1').length;<br> for (var i=len-1; i>=0; i--) {<br> if ($(this).scrollTop() >= $('.headline-1').eq(i).offset().top - $('.headline-1').eq(i).height ()) {<br>               var index = i;<br>                  $('#sideCatalog-catalog dl dd').eq(index).addClass('heightlight').siblings('dd').removeClass('heightlight');<br>                  scrollSlide($('#sideCatalog-catalog dl dd').eq(index), index);<br>                        return false;<br>               } sonst {<br>                  $('#sideCatalog-catalog dl dd').eq(0).addClass('heightlight').siblings('dd').removeClass('heightlight');<br>             }<br> }<br> })</p> <p> //Scrollen der Navigation und Anzeigen und Ausblenden von Auf- und Ab-Schaltflächen<br> Funktion scrollSlide(that, index){<br> Wenn (Index < 5) {<br />                 $('#sideCatalog-catalog dl').stop().animate({'top': '0'}, 'fast');<br />                $('#sideCatalog-down').removeClass('sideCatalog-down-disable').addClass('sideCatalog-down-enable');<br />               $('#sideCatalog-up').removeClass('sideCatalog-up-enable').addClass('sideCatalog-up-disable');<br />            } else if (index > 11) {<br>                  $('#sideCatalog-catalog dl').stop().animate({'top': -enableTop}, 'fast');<br>                 $('#sideCatalog-down').removeClass('sideCatalog-down-enable').addClass('sideCatalog-down-disable');<br>                 $('#sideCatalog-up').removeClass('sideCatalog-up-disable').addClass('sideCatalog-up-enable');<br>          } sonst {<br>                 var dlTop = parseInt($('#sideCatalog-catalog dl').css('top')) slideOutHeight / 2 - (that.offset().top - $(document).scrollTop());<br>                  $('#sideCatalog-catalog dl').stop().animate({'top': dlTop}, 'fast');<br>                $('#sideCatalog-down').removeClass('sideCatalog-down-disable').addClass('sideCatalog-down-enable');<br>                 $('#sideCatalog-up').removeClass('sideCatalog-up-disable').addClass('sideCatalog-up-enable');<br> }<br> }<br> </script>


Die große Website hat den Stil einer großen Website. Viele der Effekte werden von ihnen zuerst erstellt und verwendet. Freunde können oft einkaufen und leicht einige gute Dinge finden

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn