1

I have a Div with 395px of Height, and overflow hidden, like this:

<style>
   ​#content {
       width: 100%;
       height: 395px;
       overflow: hidden;
}​
</style>

<div id="content">
    1<br>2<br>3<br>4<br>......<br>29<br>30<br>
    1<br>2<br>3<br>4<br>......<br>29<br>30<br>
</div>

<a href="#">UP</a>
<a href="#">DOWN</a>​​​​​​​​​

The buttons should scroll the content of the div, but not in Mouse Over, I want to a single click scroll 132px of height and with EaseOutCubic. I found a lot of scroller, but all with Mouse over, I need them working with the Mouse Click.

4

1 回答 1

2

你可以使用这样的东西

<style>
   ​#content {
       width: 100%;
       height: 395px;
       overflow: scroll;
}​
</style>

<div id="content">
    1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>
    11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>
    21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>
    1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>
    11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>
    21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>
</div>

<a href="#" class="up">UP</a>
<a href="#" class="up">DOWN</a>​​​​​​​​​

<script type="text/javascript">
(jQuery.noConflict())(function($){
  $('a.up').click(function(){
    var newTop = $('#content').scrollTop() + 132;
    //TODO: newtop not greater than height - 132
    $('#content').animate({'scrollTop': newTop}, 250);
  });
});
</script>
于 2012-08-10T19:09:43.767 回答