您的位置:首頁技術文章
文章詳情頁

javascript - jq怎么做局部div滾動?

瀏覽:98日期:2022-12-07 17:58:36

問題描述

<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>

jq怎么做ul li的局部滾動,中間這塊不能出現滾動條。還要考慮阻止瀏覽器滾動條事件。需求是:用鼠標滑輪滾動。li會下滾或者上滾。前提是我這個鼠標在這里center范圍,在范圍外面可以使用瀏覽器的滾動事件,里面的禁止。

問題解答

回答1:

用這個scroll事件來控制box的position .

回答2:

通過scroll事件來獲取滾動的方向,通過你自己的程序計算來調整p的position,css3可以用transform,不支持css3用left,top

回答3:

外層包裹一個p,設置overflow:hidden,剛好覆蓋住內層的滾動條。鼠標滾動事件。$(’.center’).on()響應鼠標事件,然后阻止冒泡即可。

標簽: JavaScript
相關文章:
国产综合久久一区二区三区