In view of many previous front-end frameworks (especially responsive layout frameworks), UI controls look too much like web pages and have no native feel. Therefore, the pursuit of native UI is also an important goal of MUI. MUI is based on the iOS platform UI and supplements some UI controls unique to the Android platform. MUI mainly has three meanings: 1. A multilingual version of Windows, a separately released computer operating system; 2. the world's most authoritative official organization for Halal certification; 3. a proper noun in mobile communication technology. This article mainly introduces the relevant information on the use of mobile HTML5 front-end framework-MUI. The editor thinks it is quite good. Now I will share it with you and give you a reference. I hope it can help everyone.
1. Preparations before using the framework
1. Create a new HTML file containing mui
In Hbuilder, create a new HTML file and select "HTML containing mui" Template can quickly generate a mui page template, which handles mui's js and css resource references by default.
2. Enter mheader
The top title bar is required for every page. Enter mheader in Hbuilder to quickly generate the top navigation bar.
3. Enter mbody
Except for the top navigation and bottom tab controls, it is recommended that other controls be placed in the .mui-content control. Enter mbody in Hbuilder to quickly Generate a code block containing .mui-content.
2. UI components
1.accordion(folding panel)
The folding panel is similar to the secondary list, as follows:
-
面板1
面板1子内容
-
面板2
面板2子内容
2.buttons(buttons)
Normal buttons
Add the .mui-btn class to the button node to generate the default button; if you need buttons of other colors, then Just continue to add the corresponding class. For example, .mui-btn-blue can become a blue button
<button>默认</button> <button>蓝色</button> <button>绿色</button> <button>黄色</button> <button>红色</button> <button>紫色</button>
The effect after running is as follows:
If If you want buttons with no background color and borders, you only need to add the .mui-btn-outlined class. The code is as follows:
<button>默认</button> <button>蓝色</button> <button>绿色</button> <button>黄色</button> <button>红色</button> <button>紫色</button>
The running results are as follows:
3.gallery(picture carousel)
The picture carousel inherits from the slide plug-in, so its DOM structure and events are the same as the slide plug-in;
Loop playback is not supported by default, and the DOM structure As follows:
<p> </p><p> </p><p><a><img src="/static/imghwm/default1.png" data-src="1.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="2.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="3.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="4.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p>
Assume that there are four pictures 1, 2, 3, and 4 in the current picture carousel. Starting from the 1st picture, slide left to switch pictures. When switching to the 4th picture, Continue to slide left, and there will be two effects:
Supports looping: slide left to switch directly to the first picture;
Looping is not supported: swipe left, no response, continue to display the 4th picture. If the user wants to display the 1st picture, he must continuously swipe right to switch to the 1st picture;
When the first picture is displayed, it is the same problem to continue to slide right to display the fourth picture; the implementation of this problem needs to be controlled through the .mui-slider-loop class and DOM nodes;
To To support looping, you need to add the .mui-slider-loop class to the .mui-slider-group node. At the same time, you need to repeatedly add 2 pictures. The order of the pictures becomes: 4, 1, 2, 3, 4, 1. Code example As follows:
<p> </p><p> <!--支持循环,需要重复图片节点--> </p><p><a><img src="/static/imghwm/default1.png" data-src="4.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="1.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="2.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="3.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <p><a><img src="/static/imghwm/default1.png" data-src="4.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p> <!--支持循环,需要重复图片节点--> <p><a><img src="/static/imghwm/default1.png" data-src="1.jpg" class="lazy" alt="How to use the MUI framework in mobile HTML5" ></a></p>
The mui framework has a built-in image carousel plug-in. Through the JS API encapsulated by this plug-in, users can set whether to automatically carousel and the carousel cycle. The following is a code example:
//获得slider插件对象 var gallery = mui('.mui-slider'); gallery.slider({ interval:3000//自动轮播周期,若为0则不自动播放,默认为0; });
So if you want the picture carousel not to play automatically, but to be switched by the user's manual sliding, you only need to set the interval parameter to 0 through the above method.
If you want to jump to the xth picture, you can use the gotoItem method of the picture carousel plug-in, for example:
//mui自带的on事件绑定,只能用事件委派方式 mui(".mui-content").on("tap","#btn",function(){ gallery.slider().gotoItem(2);//调到第三张图片,index从0开始 });
4.input (input form)
All Elements such as input and textarea wrapped in the .mui-input-row class will have the width attribute set to width: 100%; by default. Wrapping the label element and the above controls in a .mui-input-group provides the best arrangement.
(There is also an eye icon on the right side of the password input box, which I find particularly useful)
The code is as follows:
mui currently also provides several input enhancement functions: quick deletion, voice input *5+ only and password box display hidden password.
1) Quick deletion: Just add the .mui-input-clear class to the input control. When there is content in the input control, there will be a delete icon on the right. Clicking it will clear the current input content
The code is as follows:
2) Search box: Add the .mui-input-search class at the same level as .mui-input-row and you can use it search control
The code is as follows:
<p> <input> </p>
3) Voice input*5+ only: In order to facilitate quick input, mui integrates HTML5+ voice input, only You need to add the .mui-input-speech class to the corresponding input control to use voice input in the 5+ environment
4)密码框:给input元素添加.mui-input-password类即可使用
代码如下:
5.list(列表)
mui封装的列表组件是比较简单也很好用的。只需要在ul节点上添加.mui-table-view类、在li节点上添加.mui-table-view-cell类即可
- Item 1
- Item 2
- Item 3
运行结果如下图:
自定义列表高亮颜色
点击列表,对应列表项显示灰色高亮,若想自定义高亮颜色,只需要重写.mui-table-view-cell.mui-active即可,如下:
/*点击变灰色高亮*/ .mui-table-view-cell.mui-active{ background-color: gray; }
右侧添加导航箭头
若右侧需要增加导航箭头,变成导航链接,则只需在li节点下增加a子节点,并为该a节点增加.mui-navigate-right类即可,如下:
运行结果如下:
右侧添加数字角标等控件
mui支持将数字角标、按钮、开关等控件放在列表中;mui默认将数字角标放在列表右侧显示,代码如下:
- Item 1 1
- Item 2 2
- Item 3 3
运行结果如下:
(图文列表)
图文列表继承自列表组件,主要添加了.mui-media、.mui-media-object、.mui-media-body、.mui-pull-left/right几个类,如下为示例代码
运行结果如下:
结束语:mui框架使用起来确实很方便,它还有很多控件供我们使用,具体可在mui官网查看。
相关推荐:
The above is the detailed content of How to use the MUI framework in mobile HTML5. For more information, please follow other related articles on the PHP Chinese website!

html5的div元素默认一行不可以放两个。div是一个块级元素,一个元素会独占一行,两个div默认无法在同一行显示;但可以通过给div元素添加“display:inline;”样式,将其转为行内元素,就可以实现多个div在同一行显示了。

html5中列表和表格的区别:1、表格主要是用于显示数据的,而列表主要是用于给数据进行布局;2、表格是使用table标签配合tr、td、th等标签进行定义的,列表是利用li标签配合ol、ul等标签进行定义的。

固定方法:1、使用header标签定义文档头部内容,并添加“position:fixed;top:0;”样式让其固定不动;2、使用footer标签定义尾部内容,并添加“position: fixed;bottom: 0;”样式让其固定不动。

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

html5中不支持的标签有:1、acronym,用于定义首字母缩写,可用abbr替代;2、basefont,可利用css样式替代;3、applet,可用object替代;4、dir,定义目录列表,可用ul替代;5、big,定义大号文本等等。

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

html5是指超文本标记语言(HTML)的第五次重大修改,即第5代HTML。HTML5是Web中核心语言HTML的规范,用户使用任何手段进行网页浏览时看到的内容原本都是HTML格式的,在浏览器中通过一些技术处理将其转换成为了可识别的信息。HTML5由不同的技术构成,其在互联网中得到了非常广泛的应用,提供更多增强网络应用的标准机。

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
