jQuery+css实现百度百科的页面导航效果(3)

<div>
        content10,content10
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </div>
    <h2>
        <a></a>
        <span>11</span>
        <span>part11</span>
    </h2>

<div>
        content11,content11
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </div>
    <h2>
        <a></a>
        <span>12</span>
        <span>part12</span>
    </h2>

<div>
        content12,content12
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </div>
    <h2>
        <a></a>
        <span>13</span>
        <span>part13</span>
    </h2>

<div>
        content13,content13
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </div>
    <h2>
        <a></a>
        <span>14</span>
        <span>part14</span>
    </h2>

<div>
        content14,content14
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </div>
    <h2>
        <a></a>
        <span>15</span>
        <span>part15</span>
    </h2>

<div>
        content15,content15
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        bottom
    </div>
</div>
<div>
    <div>
        <div>
            <div>
                <div></div>
                <div></div>
            </div>
            <div>
                <div title="向上翻页"></div>
                <div title="向下翻页"></div>
            </div>
            <div>
                <dl>
                    <dd>
                        <span>1</span>
                        <a title="part1" href="#1">part1</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>2</span>
                        <a title="part2" href="#2">part2</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>2-1</span>
                        <a title="part2" href="#2-1">part2-1</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>2-2</span>
                        <a title="part2" href="#2-2">part2-2</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>3</span>
                        <a title="part3" href="#3">part3</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>4</span>
                        <a title="part4" href="#4">part4</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>5</span>
                        <a title="part5" href="#5">part5</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>6</span>
                        <a title="part6" href="#6">part6</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>7</span>
                        <a title="part7" href="#7">part7</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>8</span>
                        <a title="part8" href="#8">part8</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>9</span>
                        <a title="part9" href="#9">part9</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>10</span>
                        <a title="part10" href="#10">part10</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>11</span>
                        <a title="part11" href="#11">part11</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>12</span>
                        <a title="part12" href="#12">part12</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>13</span>
                        <a title="part13" href="#13">part13</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>14</span>
                        <a title="part14" href="#14">part14</a>
                        <span></span>
                    </dd>
                    <dd>
                        <span>15</span>
                        <a title="part15" href="#15">part15</a>
                        <span></span>
                    </dd>
                </dl>
            </div>
        </div>
        <a href="javascript:void(0);"></a>
        <a title="返回顶部" href="javascript:void(0)"></a>
    </div>
</div>
</div>
<script type="text/javascript" src="https://www.jb51.net/jquery-1.7.2.js"></script>
<script>
    var slideInnerHeight = $('#sideCatalog-catalog dl').height();
    var slideOutHeight = $('#sideCatalog-catalog').height();
    var enableTop = slideInnerHeight - slideOutHeight;
    var step = 50;
    //点击向上的按钮
    $('#sideCatalog-down').bind('click', function () {
        if ($(this).hasClass('sideCatalog-down-enable')) {
            if ((enableTop - Math.abs(parseInt($('#sideCatalog-catalog dl').css('top')))) > step) {
                $('#sideCatalog-catalog dl').stop().animate({'top': '-=' + step}, 'fast');
                $('#sideCatalog-up').removeClass('sideCatalog-up-disable').addClass('sideCatalog-up-enable');
            } else {
                $('#sideCatalog-catalog dl').stop().animate({'top': -enableTop}, 'fast');
                $(this).removeClass('sideCatalog-down-enable').addClass('sideCatalog-down-disable');
            }
        } else {
            return false;
        }
    })
    //点击向下的按钮
    $('#sideCatalog-up').bind('click', function () {
        if ($(this).hasClass('sideCatalog-up-enable')) {
            if (Math.abs(parseInt($('#sideCatalog-catalog dl').css('top'))) > step) {
                $('#sideCatalog-catalog dl').stop().animate({'top': '+=' + step}, 'fast');
                $('#sideCatalog-down').removeClass('sideCatalog-down-disable').addClass('sideCatalog-down-enable');
            } else {
                $('#sideCatalog-catalog dl').stop().animate({'top': '0'}, 'fast');
                $(this).removeClass('sideCatalog-up-enable').addClass('sideCatalog-up-disable');
            }
        } else {
            return false;
        }
    })

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgxxxp.html