学习总结
2.下载后把layui.css
,layui.js
包含到当前文件中,其中layui.js
包含jquery
3.如果想使用layui中的样式,只需要把样式名称放在标签的class
中即可
使用layui制作前端首页index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>layui前端页面框架</title>
<link rel="stylesheet" href="layui/css/layui.css" />
<script src="layui/layui.js"></script>
<link rel="stylesheet" href="css/index.css" />
</head>
<body>
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-nav layui-bg-cyan header" lay-filter="header">
<div>
<a href=""><img src="images/logo.png" alt="" /></a>
</div>
<div class="layui-nav-item">
<a href=""> 首页</a>
</div>
<div class="layui-nav-item"><a href="javascript:;">发现</a></div>
<div class="layui-nav-child">
<div></div>
</div>
<div class="layui-nav-item">
<a href="javascript:;">最新推荐</a>
<div class="layui-nav-child">
<div><a href="">博客</a></div>
<div><a href="">项目源码</a></div>
<div><a href="">项目实战</a></div>
</div>
</div>
<div class="layui-nav-item"><a href="">解决方案</a></div>
<div class="layui-nav-item"><a href="">社区</a></div>
<div class="layui-breadcrumb" lay-separator="|">
<a href="">
<span class="layui-icon layui-icon-username"></span>登录</a
>
<a href="">注册</a>
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md3">
<div
class="layui-nav layui-nav-tree layui-nav-side layui-bg-cyan"
lay-filter="aside"
>
<div class="layui-nav-item">
<a href="javascript:;">我的作品</a>
<div class="layui-nav-child">
<a href="">已分享作品</a>
<a href="">未分享作品</a>
</div>
</div>
<div class="layui-nav-item">
<a href="javascript:;">我的项目</a>
<div class="layui-nav-child">
<a href="">scratch项目</a>
<a href="">python项目</a>
</div>
</div>
<div class="layui-nav-item">
<a href="">我的素材库</a>
</div>
<div class="layui-nav-item">
<a href="">已收藏作品</a>
</div>
</div>
</div>
<div class="layui-col-md9">
<form class="layui-form" action="">
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-inline">
<input
type="text"
name="userName"
required
lay-verify="required"
placeholder="输入邮箱或者手机号"
autocomplete="off"
class="layui-input"
/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-inline">
<input
type="password"
name="passWord"
required
lay-verify="required"
placeholder="请输入密码"
autocomplete="off"
class="layui-input"
/>
</div>
<div class="layui-form-mid layui-word-aux">密码必须大于6位</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所在城市</label>
<div class="layui-input-block">
<select name="city" lay-verify="required">
<option value=""></option>
<option value="0">北京</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="checkbox" name="like[write]" title="写作" />
<input type="checkbox" name="like[read]" title="阅读" checked />
<input type="checkbox" name="like[program]" title="编程" />
<input type="checkbox" name="like[music]" title="听音乐" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否保存</label>
<div class="layui-input-block">
<input type="checkbox" name="switch" lay-skin="switch" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">性别</label>
<div class="layui-input-block">
<input type="radio" name="sex" value="男" title="男" />
<input type="radio" name="sex" value="女" title="女" checked />
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">备注</label>
<div class="layui-input-block">
<textarea
name="desc"
placeholder="请输入内容"
class="layui-textarea"
></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo">
立即提交
</button>
<button type="reset" class="layui-btn layui-btn-primary">
重置
</button>
</div>
</div>
</form>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md12 footer">
<div class="title">关于我们</div>
<div>
<div><a href="">公司简介</a></div>
<div><a href="">意见反馈</a></div>
</div>
<div class="title">服务协议</div>
<div>
<div><a href="">用户协议</a></div>
<div><a href="">免责声明</a></div>
</div>
<div class="title">友情链接</div>
<div>
<div><a href="">国际青少年编程信息网</a></div>
</div>
<div class="title">联系我们</div>
<div>
<div>
<a href=""
><span
class="layui-icon layui-icon-email"
style="color: orangered;"
></span>
573661083@qq.com</a
>
</div>
<div>
<a href=""
><span
class="layui-icon layui-icon-login-qq"
style="color: lightblue;"
></span>
573661083</a
>
</div>
</div>
<div class="title">微信公众号</div>
<div>
<div><a href="">国际青少年编程信息网</a></div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
layui.use("element", function () {
var element = layui.element;
});
layui.use("form", function () {
var form = layui.form;
});
</script>
css样式
.layui-row:nth-of-type(2) {
min-height: 600px;
}
.header {
display: flex;
flex-flow: row nowrap;
align-items: center;
}
.layui-breadcrumb {
margin-left: auto;
}
.layui-nav-side {
float: none;
position: relative;
}
form {
margin-top: 10px;
}
.footer {
background-color: #314257;
margin-bottom: 5px;
height: 180px;
color: white;
border-radius: 5px;
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: repeat(2, 1fr);
grid-auto-flow: column;
place-items: center;
gap: 10px;
}
.footer > .title {
align-self: flex-end;
}
.footer > div:not(.title) {
align-self: flex-start;
}
.footer > div > div {
padding-right: 10px;
border-right: 1px solid #888;
}
.footer a {
color: #ccc;
font-size: 0.7rem;
}
.footer a:hover {
color: orangered;
}
代码显示效果