一、按钮
1、写法
<button type="button" class="layui-btn">一个标准的按钮</button>
<a href="http://www.layui.com" class="layui-btn">一个可跳转的按钮</a>
2、颜色
<button type="button" class="layui-btn layui-btn-primary">原始</button>
<button type="button" class="layui-btn">默认</button>
<button type="button" class="layui-btn layui-btn-normal">百搭</button>
<button type="button" class="layui-btn layui-btn-warm">暖色</button>
<button type="button" class="layui-btn layui-btn-danger">警告</button>
<button type="button" class="layui-btn layui-btn-disabled">禁用</button>
3、镂空
<button type="button" class="layui-btn layui-btn-primary layui-border-green">主色</button>
<button type="button" class="layui-btn layui-btn-primary layui-border-blue">百搭</button>
<button type="button" class="layui-btn layui-btn-primary layui-border-orange">暖色</button>
<button type="button" class="layui-btn layui-btn-primary layui-border-red">警告</button>
<button type="button" class="layui-btn layui-btn-primary layui-border-black">深色</button>
4、尺寸
<button type="button" class="layui-btn layui-btn-lg">大型</button>
<button type="button" class="layui-btn">正常</button>
<button type="button" class="layui-btn layui-btn-sm">小型</button>
<button type="button" class="layui-btn layui-btn-xs">迷你</button>
<button type="button" class="layui-btn layui-btn-fluid">最大化 (响应)</button>
5、圆角
<button type="button" class="layui-btn layui-btn-radius">圆角</button>
6、按钮组
<div class="layui-btn-group">
<button type="button" class="layui-btn">增加</button>
<button type="button" class="layui-btn">编辑</button>
<button type="button" class="layui-btn">删除</button>
</div>
二、表单
- 在一个容器中设定 class="layui-form" 来标识一个表单元素块,通过规范好的 HTML 结构及 CSS 类,来组装成各式各样的表单元素,并通过内置的 form 模块 来完成各种交互。
- 依赖加载模块:form (如果不加载 form 模块,select、checkbox、radio 等将无法显示,并且无法使用 form 相关功能)
1、输入框
<form class="layui-form">
<input type="text" placeholder="请输入标题" class="layui-input" />
</form>
2、下拉选择框
默认选中
<form class="layui-form">
<select>
<option value="">请选择一个老师</option>
<option value="1">天蓬</option>
<option value="2">灭绝师太</option>
<option value="3">西门大官人</option>
<option value="4">欧阳克</option>
</select>
<select>
<option value=""></option>
<option value="1">天蓬</option>
<option value="2">灭绝师太</option>
<option value="3">西门大官人</option>
<option value="4">欧阳克</option>
</select>
<select>
<option value="1">天蓬</option>
<option value="2">灭绝师太</option>
<option value="3">西门大官人</option>
<option value="4">欧阳克</option>
</select>
</form>
自定义:选中、禁用
<form class="layui-form">
<select>
<option value="1">天蓬</option>
<option value="2" selected>灭绝师太</option>
<option value="3">西门大官人</option>
<option value="4" disabled>欧阳克</option>
</select>
</form>
分组
<form class="layui-form">
<select>
<option value="">请选择</option>
<optgroup label="男老师">
<option value="1">天蓬</option>
<option value="3">西门大官人</option>
<option value="4">欧阳克</option>
</optgroup>
<optgroup label="女老师">
<option value="2">灭绝师太</option>
</optgroup>
</select>
</form>
3、单选框
默认风格
<input type="checkbox" name="" title="天蓬" checked />
<input type="checkbox" name="" title="灭绝师太" />
<input type="checkbox" name="" title="欧阳克" disabled />
原始风格
<input type="checkbox" name="" title="天蓬" lay-skin="primary" checked />
<input type="checkbox" name="" title="灭绝师太" lay-skin="primary" />
<input type="checkbox" name="" title="欧阳克" lay-skin="primary" disabled />
5、开关
<input type="checkbox" name="" lay-skin="switch" />
<input type="checkbox" name="" lay-skin="switch" lay-text="开启|关闭" />
<input type="checkbox" name="" lay-skin="switch" disabled />
6、文本框
<textarea name="" placeholder="请输入" class="layui-textarea"></textarea>
7、区块结构
- class="layui-form-item"
- class="layui-form-label"
- class="layui-input-block"
- class="layui-input-inline"
<form class="layui-form" action="">
<div class="layui-form-item">
<label class="layui-form-label">输入框</label>
<div class="layui-input-block">
<input type="text" placeholder="请输入标题" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">输入框</label>
<div class="layui-input-inline">
<input type="text" placeholder="请输入标题" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">选择框</label>
<div class="layui-input-block">
<select>
<option value="">请选择一个老师</option>
<option value="1">天蓬</option>
<option value="2">灭绝师太</option>
<option value="3">西门大官人</option>
<option value="4">欧阳克</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单选框</label>
<div class="layui-input-block">
<input type="radio" name="sex" value="nan" title="男" />
<input type="radio" name="sex" value="nv" title="女" checked />
<input type="radio" name="sex" value="" title="保密" disabled />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">多选框</label>
<div class="layui-input-block">
<input type="checkbox" name="" title="天蓬" checked />
<input type="checkbox" name="" title="灭绝师太" />
<input type="checkbox" name="" title="欧阳克" disabled />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">富文本</label>
<div class="layui-input-block">
<textarea placeholder="请输入" class="layui-textarea"></textarea>
</div>
</div>
</form>
8、表单方框
- class="layui-form-pane" 设定表单的方框风格
- class="layui-form-text"
- pane 复选框/开关/单选框,需要额外添加属性
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<label class="layui-form-label">输入框</label>
<div class="layui-input-block">
<input type="text" placeholder="请输入标题" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">输入框</label>
<div class="layui-input-inline">
<input type="text" placeholder="请输入标题" class="layui-input" />
</div>
<div class="layui-input-inline">
<input type="text" placeholder="请输入标题" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">选择框</label>
<div class="layui-input-block">
<select>
<option value="">请选择一个老师</option>
<option value="1">天蓬</option>
<option value="2">灭绝师太</option>
<option value="3">西门大官人</option>
<option value="4">欧阳克</option>
</select>
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">单选框</label>
<div class="layui-input-block">
<input type="radio" name="sex" value="nan" title="男" />
<input type="radio" name="sex" value="nv" title="女" checked />
<input type="radio" name="sex" value="" title="保密" disabled />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">多选框</label>
<div class="layui-input-block">
<input type="checkbox" name="" title="天蓬" checked />
<input type="checkbox" name="" title="灭绝师太" />
<input type="checkbox" name="" title="欧阳克" disabled />
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">富文本</label>
<div class="layui-input-block">
<textarea placeholder="请输入" class="layui-textarea"></textarea>
</div>
</div>
</form>