Blogger Information
Blog 64
fans 6
comment 2
visits 83035
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
layui前端框架的基本用法
王娇
Original
1133 people have browsed it

学习总结

1. 使用layui前端框架,需要在https://www.layui.com上下载layui的包

2.下载后把layui.css,layui.js包含到当前文件中,其中layui.js包含jquery

3.如果想使用layui中的样式,只需要把样式名称放在标签的class中即可

4.https://www.layui.com/doc使用手册地址

使用layui制作前端首页index.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>layui前端页面框架</title>
  7. <link rel="stylesheet" href="layui/css/layui.css" />
  8. <script src="layui/layui.js"></script>
  9. <link rel="stylesheet" href="css/index.css" />
  10. </head>
  11. <body>
  12. <div class="layui-container">
  13. <div class="layui-row">
  14. <div class="layui-col-md12">
  15. <div class="layui-nav layui-bg-cyan header" lay-filter="header">
  16. <div>
  17. <a href=""><img src="images/logo.png" alt="" /></a>
  18. </div>
  19. <div class="layui-nav-item">
  20. <a href=""> 首页</a>
  21. </div>
  22. <div class="layui-nav-item"><a href="javascript:;">发现</a></div>
  23. <div class="layui-nav-child">
  24. <div></div>
  25. </div>
  26. <div class="layui-nav-item">
  27. <a href="javascript:;">最新推荐</a>
  28. <div class="layui-nav-child">
  29. <div><a href="">博客</a></div>
  30. <div><a href="">项目源码</a></div>
  31. <div><a href="">项目实战</a></div>
  32. </div>
  33. </div>
  34. <div class="layui-nav-item"><a href="">解决方案</a></div>
  35. <div class="layui-nav-item"><a href="">社区</a></div>
  36. <div class="layui-breadcrumb" lay-separator="|">
  37. <a href="">
  38. <span class="layui-icon layui-icon-username"></span>登录</a
  39. >
  40. <a href="">注册</a>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="layui-row">
  46. <div class="layui-col-md3">
  47. <div
  48. class="layui-nav layui-nav-tree layui-nav-side layui-bg-cyan"
  49. lay-filter="aside"
  50. >
  51. <div class="layui-nav-item">
  52. <a href="javascript:;">我的作品</a>
  53. <div class="layui-nav-child">
  54. <a href="">已分享作品</a>
  55. <a href="">未分享作品</a>
  56. </div>
  57. </div>
  58. <div class="layui-nav-item">
  59. <a href="javascript:;">我的项目</a>
  60. <div class="layui-nav-child">
  61. <a href="">scratch项目</a>
  62. <a href="">python项目</a>
  63. </div>
  64. </div>
  65. <div class="layui-nav-item">
  66. <a href="">我的素材库</a>
  67. </div>
  68. <div class="layui-nav-item">
  69. <a href="">已收藏作品</a>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="layui-col-md9">
  74. <form class="layui-form" action="">
  75. <div class="layui-form-item">
  76. <label class="layui-form-label">用户名</label>
  77. <div class="layui-input-inline">
  78. <input
  79. type="text"
  80. name="userName"
  81. required
  82. lay-verify="required"
  83. placeholder="输入邮箱或者手机号"
  84. autocomplete="off"
  85. class="layui-input"
  86. />
  87. </div>
  88. </div>
  89. <div class="layui-form-item">
  90. <label class="layui-form-label">密码</label>
  91. <div class="layui-input-inline">
  92. <input
  93. type="password"
  94. name="passWord"
  95. required
  96. lay-verify="required"
  97. placeholder="请输入密码"
  98. autocomplete="off"
  99. class="layui-input"
  100. />
  101. </div>
  102. <div class="layui-form-mid layui-word-aux">密码必须大于6位</div>
  103. </div>
  104. <div class="layui-form-item">
  105. <label class="layui-form-label">所在城市</label>
  106. <div class="layui-input-block">
  107. <select name="city" lay-verify="required">
  108. <option value=""></option>
  109. <option value="0">北京</option>
  110. <option value="1">上海</option>
  111. <option value="2">广州</option>
  112. <option value="3">深圳</option>
  113. <option value="4">杭州</option>
  114. </select>
  115. </div>
  116. </div>
  117. <div class="layui-form-item">
  118. <label class="layui-form-label">爱好</label>
  119. <div class="layui-input-block">
  120. <input type="checkbox" name="like[write]" title="写作" />
  121. <input type="checkbox" name="like[read]" title="阅读" checked />
  122. <input type="checkbox" name="like[program]" title="编程" />
  123. <input type="checkbox" name="like[music]" title="听音乐" />
  124. </div>
  125. </div>
  126. <div class="layui-form-item">
  127. <label class="layui-form-label">是否保存</label>
  128. <div class="layui-input-block">
  129. <input type="checkbox" name="switch" lay-skin="switch" />
  130. </div>
  131. </div>
  132. <div class="layui-form-item">
  133. <label class="layui-form-label">性别</label>
  134. <div class="layui-input-block">
  135. <input type="radio" name="sex" value="男" title="男" />
  136. <input type="radio" name="sex" value="女" title="女" checked />
  137. </div>
  138. </div>
  139. <div class="layui-form-item layui-form-text">
  140. <label class="layui-form-label">备注</label>
  141. <div class="layui-input-block">
  142. <textarea
  143. name="desc"
  144. placeholder="请输入内容"
  145. class="layui-textarea"
  146. ></textarea>
  147. </div>
  148. </div>
  149. <div class="layui-form-item">
  150. <div class="layui-input-block">
  151. <button class="layui-btn" lay-submit lay-filter="formDemo">
  152. 立即提交
  153. </button>
  154. <button type="reset" class="layui-btn layui-btn-primary">
  155. 重置
  156. </button>
  157. </div>
  158. </div>
  159. </form>
  160. </div>
  161. </div>
  162. <div class="layui-row">
  163. <div class="layui-col-md12 footer">
  164. <div class="title">关于我们</div>
  165. <div>
  166. <div><a href="">公司简介</a></div>
  167. <div><a href="">意见反馈</a></div>
  168. </div>
  169. <div class="title">服务协议</div>
  170. <div>
  171. <div><a href="">用户协议</a></div>
  172. <div><a href="">免责声明</a></div>
  173. </div>
  174. <div class="title">友情链接</div>
  175. <div>
  176. <div><a href="">国际青少年编程信息网</a></div>
  177. </div>
  178. <div class="title">联系我们</div>
  179. <div>
  180. <div>
  181. <a href=""
  182. ><span
  183. class="layui-icon layui-icon-email"
  184. style="color: orangered;"
  185. ></span>
  186. 573661083@qq.com</a
  187. >
  188. </div>
  189. <div>
  190. <a href=""
  191. ><span
  192. class="layui-icon layui-icon-login-qq"
  193. style="color: lightblue;"
  194. ></span>
  195. 573661083</a
  196. >
  197. </div>
  198. </div>
  199. <div class="title">微信公众号</div>
  200. <div>
  201. <div><a href="">国际青少年编程信息网</a></div>
  202. </div>
  203. </div>
  204. </div>
  205. </div>
  206. </body>
  207. </html>
  208. <script>
  209. layui.use("element", function () {
  210. var element = layui.element;
  211. });
  212. layui.use("form", function () {
  213. var form = layui.form;
  214. });
  215. </script>

css样式

  1. .layui-row:nth-of-type(2) {
  2. min-height: 600px;
  3. }
  4. .header {
  5. display: flex;
  6. flex-flow: row nowrap;
  7. align-items: center;
  8. }
  9. .layui-breadcrumb {
  10. margin-left: auto;
  11. }
  12. .layui-nav-side {
  13. float: none;
  14. position: relative;
  15. }
  16. form {
  17. margin-top: 10px;
  18. }
  19. .footer {
  20. background-color: #314257;
  21. margin-bottom: 5px;
  22. height: 180px;
  23. color: white;
  24. border-radius: 5px;
  25. display: grid;
  26. grid-template-columns: repeat(5, 1fr);
  27. grid-template-rows: repeat(2, 1fr);
  28. grid-auto-flow: column;
  29. place-items: center;
  30. gap: 10px;
  31. }
  32. .footer > .title {
  33. align-self: flex-end;
  34. }
  35. .footer > div:not(.title) {
  36. align-self: flex-start;
  37. }
  38. .footer > div > div {
  39. padding-right: 10px;
  40. border-right: 1px solid #888;
  41. }
  42. .footer a {
  43. color: #ccc;
  44. font-size: 0.7rem;
  45. }
  46. .footer a:hover {
  47. color: orangered;
  48. }

代码显示效果

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post