Below I will share with you an article on how to implement MUI side-sliding menu and its main part to slide up and down. It has a good reference value and I hope it will be helpful to everyone.
The introduction of the side-sliding menu in the MUI document does not explain how to implement side-sliding. The MUI side-sliding menu does not have the up and down sliding function by default and needs to be activated.
1. First add the ID to the element of class="mui-scroll-wrapper":
<!-- 侧滑导航根容器 --> <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> </p> </aside> <!-- 主页面容器 --> <p class="mui-inner-wrap"> <!-- 主页面标题 --> <header class="mui-bar mui-bar-nav"> <a 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> </p> </p> </p>
As can be seen from the above example , IDs are added to both the side sliding menu and the main part.
are: offCanvasSideScroll, offCanvasContentScroll
2. Secondly, activate in JS:
mui('#offCanvasSideScroll').scroll(); mui('#offCanvasContentScroll').scroll();
You’re done. Now you can slide down after exceeding the height. Note that it exceeds the height! Just like a browser, if the "specific display content of the main interface" does not exceed the range, there is no sliding function.
MUI: MUI sliding menu.
Complete code:
<!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></title> <script src="http://dev.dcloud.net.cn/mui/dist/js/mui.min.js"></script> <link href="http://dev.dcloud.net.cn/mui/dist/css/mui.min.css" rel="external nofollow" rel="stylesheet"/> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.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>
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to implement the exchange method of two variable values in JS
How to implement custom instructions in Vue ?
How to modify the style of child components through parent components in vue
The above is the detailed content of How to implement side sliding menu in MUI. For more information, please follow other related articles on the PHP Chinese website!