认识
- mui默认按钮为灰色,另外还提供了蓝色(blue)、绿色(green)、黄色(yellow)、红色(red)、紫色(purple)五种色系的按钮,五种色系对应五种场景,分别为primary、success、warning、danger、royal;使用.mui-btn类即可生成一个默认按钮,继续添加.mui-btn-颜色值或.mui-btn-场景可生成对应色系的按钮,例如:通过.mui-btn-blue或.mui-btn-primary均可生成蓝色按钮;
![微信公众号:JavaWeb架构师](https://i-blog.csdnimg.cn/blog_migrate/d42d1dd50b78dc08ead3cb524317a960.webp?x-image-process=image/format,png)
有背景色
- 在button节点上增加.mui-btn类,即可生成默认按钮;若需要其他颜色的按钮,则继续增加对应class即可,比如.mui-btn-blue即可变成蓝色按钮。
<div class="styleBtn">
<button type="button" class="mui-btn">默认</button>
<button type="button" class="mui-btn mui-btn-red">红色</button>
<button type="button" class="mui-btn mui-btn-blue">蓝色</button>
<button type="button" class="mui-btn mui-btn-green">绿色</button>
<button type="button" class="mui-btn mui-btn-yellow">黄色</button>
<button type="button" class="mui-btn mui-btn-purple">紫色</button>
</div>
![微信公众号:JavaWeb架构师](https://i-blog.csdnimg.cn/blog_migrate/7c35a11e45c8ae8bd5cd94f147a905b9.webp?x-image-process=image/format,png)
无背景色、有边框
- 若希望无底色、有边框的按钮,仅需增加.mui-btn-outlined类即可。
<div class="styleBtn">
<button type="button" class="mui-btn mui-btn-outlined">默认</button>
<button type="button" class="mui-btn mui-btn-red mui-btn-outlined">红色</button>
<button type="button" class="mui-btn mui-btn-blue mui-btn-outlined">蓝色</button>
<button type="button" class="mui-btn mui-btn-green mui-btn-outlined">绿色</button>
<button type="button" class="mui-btn mui-btn-yellow mui-btn-outlined">黄色</button>
<button type="button" class="mui-btn mui-btn-purple mui-btn-outlined">紫色</button>
</div>
![微信公众号:JavaWeb架构师](https://i-blog.csdnimg.cn/blog_migrate/cd4c28deb5cb99ca83d11bd855dab1a2.webp?x-image-process=image/format,png)
自定义样式
- 设置button的background-color和color属性就行。
.mui-button-diy {
background-color: #EC971F;
color: #8A6DE9;
}
<div class="styleBtn">
<button type="button" class="mui-btn mui-button-diy">默认</button>
<button type="button" class="mui-btn mui-button-diy">红色</button>
<button type="button" class="mui-btn mui-button-diy">蓝色</button>
<button type="button" class="mui-btn mui-button-diy">绿色</button>
<button type="button" class="mui-btn mui-button-diy">黄色</button>
<button type="button" class="mui-btn mui-button-diy">紫色</button>
</div>
![微信公众号:JavaWeb架构师](https://i-blog.csdnimg.cn/blog_migrate/f6e36b45d720de9d670635ecd4d5bea2.webp?x-image-process=image/format,png)
测试代码
<!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="js/mui.min.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<script type="text/javascript" charset="utf-8">
mui.init();
</script>
<style type="text/css">
.styleBtn {
margin-top: 20px;
text-align: center;
}
.mui-button-diy {
background-color: #EC971F;
color: #8A6DE9;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">按钮(button)</h1>
</header>
<div class="mui-content">
<div class="styleBtn">
<button type="button" class="mui-btn">默认</button>
<button type="button" class="mui-btn mui-btn-red">红色</button>
<button type="button" class="mui-btn mui-btn-blue">蓝色</button>
<button type="button" class="mui-btn mui-btn-green">绿色</button>
<button type="button" class="mui-btn mui-btn-yellow">黄色</button>
<button type="button" class="mui-btn mui-btn-purple">紫色</button>
</div>
<div class="styleBtn">
<button type="button" class="mui-btn mui-btn-outlined">默认</button>
<button type="button" class="mui-btn mui-btn-red mui-btn-outlined">红色</button>
<button type="button" class="mui-btn mui-btn-blue mui-btn-outlined">蓝色</button>
<button type="button" class="mui-btn mui-btn-green mui-btn-outlined">绿色</button>
<button type="button" class="mui-btn mui-btn-yellow mui-btn-outlined">黄色</button>
<button type="button" class="mui-btn mui-btn-purple mui-btn-outlined">紫色</button>
</div>
<div class="styleBtn">
<button type="button" class="mui-btn mui-button-diy">默认</button>
<button type="button" class="mui-btn mui-button-diy">红色</button>
<button type="button" class="mui-btn mui-button-diy">蓝色</button>
<button type="button" class="mui-btn mui-button-diy">绿色</button>
<button type="button" class="mui-btn mui-button-diy">黄色</button>
<button type="button" class="mui-btn mui-button-diy">紫色</button>
</div>
</div>
</body>
</html>
效果
![微信公众号:JavaWeb架构师](https://i-blog.csdnimg.cn/blog_migrate/ea07d0952b05dc0e0f01e729958ee581.webp?x-image-process=image/format,png)
源码下载
关注下方的微信公众号,回复:007_按钮之普通按钮(button).code
![](https://i-blog.csdnimg.cn/blog_migrate/fb72e6bbf4abb77137dfe85b3e35e8d1.webp?x-image-process=image/format,png)
欢迎加入交流群:451826376
更多信息:www.itcourse.top
![完整教程PDF版本下载](https://i-blog.csdnimg.cn/blog_migrate/2c83ba9afc73a546e591e4a4e4e56b2b.webp?x-image-process=image/format,png)