javascript - jq怎么做局部div滾動?
問題描述
<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()響應鼠標事件,然后阻止冒泡即可。
相關文章:
1. 求救一下,用新版的phpstudy,數據庫過段時間會消失是什么情況?2. php - mysql 模糊搜索問題3. javascript - 在 vue里面用import引入js文件,結果為undefined4. php工具箱配置第二個vhost主機時不生效,報錯You don’t have permission5. php - 微信開發驗證服務器有效性6. javascript - 求幫助 , ATOM不顯示界面!!!!7. javascript - js setTimeout在雙重for循環中如何使用?8. html - 爬蟲時出現“DNS lookup failed”,打開網頁卻沒問題,這是什么情況?9. [python2]local variable referenced before assignment問題10. javascript - 我的站點貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?
