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. android-webview - Android 7.0 webview不自动刷新2. java - C++ error C2678: 二进制“<<”: 没有找到接受“const std::ostream”类型的左操作数的运算符3. vue.js - vue开发的项目,想在页面打开的时候使input自动聚焦,使用的官方的自定义指令,但是在ios真机上测试无效4. Java EE 6:JSF与Servlet + JSP我应该学习JSF吗?5. Java错误:只能导入类型XYZ解析为包6. python - 用ffmpeg采集视频,用terminate没法结束进程7. shell - mac bash: mysql: command not found8. python3 snmp大家都用什么扩展模块9. mysql - E-R图转换为关系数据模型?10. django - python 读写 setting.py文件

网公网安备