核心提示:mui实现侧滑菜单及主体部分上下滑动的代码实例教程!DOCTYPE htmlhtmlheadmeta charset=utf-8meta name=viewport content=width=dev...
mui实现侧滑菜单及主体部分上下滑动的代码实例教程
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <title>mui实现侧滑菜单及主体部分上下滑动</title> <link rel="stylesheet" href="../mui-master/mui-master/dist/css/mui.min.css"> <script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="../mui-master/mui-master/dist/js/mui.min.js"></script> <style type="text/css"> body{ background-color: #000000; } .mui-off-canvas-wrap{ max-width: 720px; margin: 0 auto; } </style> </head> <body> <!-- 侧滑导航根容器 --> <p class="mui-off-canvas-wrap mui-draggable"> <!-- 菜单容器 --> <aside class="mui-off-canvas-left"> <p id="offCanvasSideScroll" class="mui-scroll-wrapper"> <p class="mui-scroll"> <!-- 菜单具体展示内容 --> <p style="height:1000px"> </p> </p> </p> </aside> <!-- 主页面容器 --> <p class="mui-inner-wrap"> <!-- 主页面标题 --> <header class="mui-bar mui-bar-nav"> <a id="left-menu" class="mui-icon mui-action-menu mui-icon-bars mui-pull-left"></a> <h1 class="mui-title">标题</h1> </header> <p id="offCanvasContentScroll" class="mui-content mui-scroll-wrapper"> <p class="mui-scroll"> <!-- 主界面具体展示内容 --> <p style="height:1000px"> </p> </p> </p> </p> </p> <script type="text/javascript" charset="utf-8"> $("#left-menu").on('tap', function (event) { mui('.mui-off-canvas-wrap').offCanvas('show'); }); window.onload = function(){ mui('#offCanvasSideScroll').scroll(); mui('#offCanvasContentScroll').scroll(); } </script> </body> </html>
二、如果不自定义滚动区域的话,也可以不用给滚动区域设置高度
自定义滚动区域肯定要设置高度。
但是假设你的自定义区域就是mui-content区域。
那么使用的时候,应该把mui-content和mui-scroll-wrapper放在一起就可以了。这样就不需要设置高度了。
<p id="scroll" class="mui-content mui-scroll-wrapper"> <p class="mui-scroll"> <p class="mui-loading"> <p class="mui-spinner"> </p> </p> </p> </p>