search

Home  >  Q&A  >  body text

javascript - How to do local div scrolling in jq?

<style>
.top , .bottom{height:130px;background:#000;} .center{height:400px;overflow:hidden;position:relative;}
.center .box{ width:100%;height:100%;position:absolute;}
.center .box ul{overflow:hidden;}
.center .box ul li{background:red;height:400px;width:100 %;}
</style>

<p class="top"></p>

<p class="center">
    <p class="box">
        <ul>
        <li></li>
        <li></li>
        </ul>
    </p>
</p>

<p class="bottom"></p>

How does jq do partial scrolling of ul li? No scroll bar can appear in the middle. Also consider blocking browser scrollbar events.
The requirement is: scroll with the mouse wheel. li will scroll down or up. The premise is that my mouse is in the center range here. The browser's scroll event can be used outside the range, but it is prohibited inside.

phpcn_u1582phpcn_u15822746 days ago761

reply all(3)I'll reply

  • 黄舟

    黄舟2017-05-24 11:38:08

    Use this scroll event to control the position of the box.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-24 11:38:08

    Get the scrolling direction through the scroll event, and adjust the position of p through your own program calculation. You can use transform for css3. If css3 is not supported, use left and top.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-24 11:38:08

    Wrap a p in the outer layer and set overflow:hidden to just cover the inner scroll bar.
    Mouse scroll event. $('.center').on() responds to mouse events and then prevents bubbling.

    reply
    0
  • Cancelreply