博客列表 >Flex布局小案例-九期线上班

Flex布局小案例-九期线上班

Content っ
Content っ 原创
2019年11月11日 14:48:32390浏览

1.将课堂介绍了三个小案例, 自己动手写一遍, 再抄一遍

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>将课堂介绍了三个小案例, 自己动手写一遍, 再抄一遍</title>
  6. <link rel="stylesheet" href="css/style1.css">
  7. </head>
  8. <body>
  9. <header>我的博客</header>
  10. <main>
  11. <div class="container">
  12. <h3>后台管理系统</h3>
  13. <form action="">
  14. <div>
  15. <label for="email">邮箱:</label>
  16. <input type="email" name="email" id="email" placeholder="xx@qq.com">
  17. </div>
  18. <div>
  19. <label for="password">密码:</label>
  20. <input type="password" name="password" id="password" placeholder="输入6位以上密码">
  21. </div>
  22. <div>
  23. <button>登录</button>
  24. </div>
  25. </form>
  26. </div>
  27. <aside>左边</aside>
  28. <aside>右边</aside>
  29. </main>
  30. <footer>
  31. <a href="">网站首页</a>
  32. <a href="">管理后台</a>
  33. <a href="">关于我们</a>
  34. </footer>
  35. </body>
  36. </html>
  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. header,footer {
  6. background-color: #ccddcc;
  7. height: 50px;
  8. display: flex;
  9. flex-flow: row nowrap;
  10. justify-content: center;
  11. align-items: center;
  12. }
  13. body{
  14. height: 100vh;
  15. display: flex;
  16. flex-flow: column nowrap;
  17. }
  18. main{
  19. display: flex;
  20. flex-flow: row nowrap;
  21. box-sizing: border-box;
  22. border-bottom: 1px solid #ccc;
  23. border-top: 1px solid #ccc;
  24. flex: 1;
  25. }
  26. footer > a{
  27. text-decoration: none;
  28. color: #555555;
  29. display: flex;
  30. flex: 1;
  31. border-right: 1px solid #fff;
  32. justify-content: center;
  33. align-items: center;
  34. }
  35. /*设置底部"关于我们"标签*/
  36. footer > a:last-of-type{
  37. border-right: none;
  38. }
  39. /*设置主体区域*/
  40. main > article{
  41. background-color: lightblue;
  42. flex: 1;
  43. }
  44. /*设置左边*/
  45. main > aside:first-of-type{
  46. background-color: lightgreen;
  47. flex: 0 1 200px;
  48. order: -1;
  49. }
  50. /*设置右边区域*/
  51. main > aside:last-of-type{
  52. background-color: lightcoral;
  53. flex: 0 1 200px;
  54. }
  55. /*主体登录区域*/
  56. .container{
  57. box-sizing: border-box;
  58. background: -webkit-linear-gradient(bottom,lavenderblush,lightblue);
  59. display: flex;
  60. flex-flow: column nowrap;
  61. flex: 1;
  62. justify-content: center;
  63. align-items: center;
  64. }
  65. .container > form{
  66. background: -webkit-linear-gradient(right,white,lightblue,white);
  67. border: 1px solid #999999;
  68. border-radius: 5px;
  69. width: 300px;
  70. height: 150px;
  71. padding: 10px;
  72. display: flex;
  73. flex-flow: column nowrap;
  74. }
  75. .container > h3{
  76. margin-bottom: 15px;
  77. font-weight: lighter;
  78. color: #444;
  79. }
  80. .container > form > div{
  81. display: flex;
  82. margin: 10px;
  83. }
  84. .container > form > div > label{
  85. font-weight: lighter;
  86. color: #444;
  87. }
  88. /*设置input标签的样式*/
  89. .container > form > div > input{
  90. flex: 1;
  91. border: 1px solid #888;
  92. border-radius: 8px;
  93. margin-left: 3px;
  94. padding: 3px;
  95. }
  96. /*设置登录按钮的样式*/
  97. .container > form > div > button{
  98. flex: 1;
  99. height: 28px;
  100. background-color: lightseagreen;
  101. color: white;
  102. /*设置字间距*/
  103. letter-spacing: 15px;
  104. /*重置按钮边框,先去掉之前的*/
  105. border: none;
  106. /*设置圆角*/
  107. border-radius: 8px;
  108. }
  109. /*设置鼠标移入表单的效果*/
  110. .container > form:hover {
  111. /*更新背景渐变色*/
  112. background: linear-gradient(to left top, lightcyan, white);
  113. /*边框阴影模拟外发光效果*/
  114. box-shadow: 0 0 5px #888;
  115. }
  116. .container > form > div > input:hover {
  117. /*更新按钮背景色*/
  118. border: 1px solid lightcoral;
  119. }
  120. /*设置鼠标移入按钮的效果*/
  121. .container > form > div > button:hover {
  122. /*更新按钮背景色*/
  123. background-color: lightcoral;
  124. /*边框阴影模拟外发光效果*/
  125. box-shadow: 0 0 5px #888;
  126. }

运行效果

手抄代码



2.自己根据自己情况, 自定义一个小案例, 使用flex实现, 例如网站后台首页

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>网站后台首页</title>
  6. <link rel="stylesheet" href="css/style2.css">
  7. </head>
  8. <body>
  9. <header>
  10. <h2>采售一体化管理平台</h2>
  11. <div>
  12. <img src="images/img6.png" alt="">
  13. <img src="images/img2.png" alt="">
  14. <img src="images/img4.png" alt="">
  15. </div>
  16. </header>
  17. <main>
  18. <div class="container">
  19. <article>
  20. <img src="images/img6.png" alt="">
  21. <p>快捷菜单</p>
  22. </article>
  23. <article>
  24. <img src="images/img6.png" alt="">
  25. <p>快捷菜单</p>
  26. </article>
  27. <article>
  28. <img src="images/img6.png" alt="">
  29. <p>快捷菜单</p>
  30. </article>
  31. <article>
  32. <img src="images/img6.png" alt="">
  33. <p>快捷菜单</p>
  34. </article>
  35. <article>
  36. <img src="images/img6.png" alt="">
  37. <p>快捷菜单</p>
  38. </article>
  39. <div class="tableDiv">
  40. <table>
  41. <caption><h3>货物清单</h3></caption>
  42. <!--表头-->
  43. <thead>
  44. <tr>
  45. <th>类别</th>
  46. <th>编号</th>
  47. <th>名称</th>
  48. <th>单价</th>
  49. <th>数量</th>
  50. <th>金额</th>
  51. </tr>
  52. </thead>
  53. <!--主体-->
  54. <tbody>
  55. <tr>
  56. <td rowspan="3" align="center">手机类</td>
  57. <td>1</td>
  58. <td>iPhone 11 Pro</td>
  59. <td>9999</td>
  60. <td>1</td>
  61. <td>9999</td>
  62. </tr>
  63. <tr>
  64. <td>2</td>
  65. <td>HUAWEI P30 Pro</td>
  66. <td>6288</td>
  67. <td>2</td>
  68. <td>12576</td>
  69. </tr>
  70. <tr>
  71. <td>3</td>
  72. <td>Galaxy Note10</td>
  73. <td>7999</td>
  74. <td>10</td>
  75. <td>79990</td>
  76. </tr>
  77. <tr>
  78. <td rowspan="3" align="center">电脑类</td>
  79. <td>4</td>
  80. <td>华为(2019)MateBookX Pro</td>
  81. <td>8699</td>
  82. <td>1</td>
  83. <td>8699</td>
  84. </tr>
  85. <tr>
  86. <td>5</td>
  87. <td>苹果(2019)MacBook Pro</td>
  88. <td>18199</td>
  89. <td>1</td>
  90. <td>18199</td>
  91. </tr>
  92. <tr>
  93. <td>6</td>
  94. <td>ThinkPad(2019)X1 extreme</td>
  95. <td>13500</td>
  96. <td>1</td>
  97. <td>13500</td>
  98. </tr>
  99. </tbody>
  100. <!--页眉-->
  101. <tfoot>
  102. <tr>
  103. <td colspan="4" align="center">总计:</td>
  104. <td>16</td>
  105. <td>142963</td>
  106. </tr>
  107. </tfoot>
  108. </table>
  109. </div>
  110. </div>
  111. <div class="leftDiv">
  112. <span class="item">系统首页</span>
  113. <span class="item">档案管理</span>
  114. <span class="item">日常业务</span>
  115. <span class="item">采集管理</span>
  116. <span class="item">结算管理</span>
  117. <span class="item">收费管理</span>
  118. <span class="item">控制管理</span>
  119. <span class="item">查询</span>
  120. <span class="item">报表</span>
  121. <span class="item">系统管理</span>
  122. </div>
  123. </main>
  124. <footer>
  125. <p>Copyright © 2018 -2021 采售一体化管理平台</p>
  126. </footer>
  127. </body>
  128. </html>
  1. *{
  2. margin: 0;
  3. padding: 0;
  4. }
  5. header{
  6. background-color: #B3B3B3;
  7. height: 60px;
  8. display: flex;
  9. flex-flow: row nowrap;
  10. }
  11. header > h2{
  12. color: white;
  13. text-align: center;
  14. margin-top: 10px;
  15. }
  16. header > div{
  17. display: flex;
  18. flex: 1;
  19. justify-content: flex-end;
  20. align-items: center;
  21. margin: 10px;
  22. }
  23. header > div > img{
  24. width: 35px;
  25. height: 35px;
  26. margin: 10px;
  27. padding-right: 10px;
  28. border-right: 1px solid #999;
  29. }
  30. header > div > img:last-of-type {
  31. border-right: none;
  32. }
  33. footer {
  34. background-color: #ccddcc;
  35. height: 50px;
  36. display: flex;
  37. flex-flow: row nowrap;
  38. justify-content: center;
  39. align-items: center;
  40. }
  41. body{
  42. height: 100vh;
  43. display: flex;
  44. flex-flow: column nowrap;
  45. }
  46. main{
  47. display: flex;
  48. flex-flow: row nowrap;
  49. box-sizing: border-box;
  50. border-bottom: 1px solid #ccc;
  51. border-top: 1px solid #ccc;
  52. flex: 1;
  53. }
  54. footer > a{
  55. text-decoration: none;
  56. color: #555555;
  57. display: flex;
  58. flex: 1;
  59. border-right: 1px solid #fff;
  60. justify-content: center;
  61. align-items: center;
  62. }
  63. /*设置底部"关于我们"标签*/
  64. footer > a:last-of-type{
  65. border-right: none;
  66. }
  67. /*设置主体区域*/
  68. main > article{
  69. background-color: lightblue;
  70. flex: 1;
  71. }
  72. /*设置左边*/
  73. main > .leftDiv{
  74. display: flex;
  75. background-color: lightsteelblue;
  76. width: 130px;
  77. min-width: 130px;
  78. flex-flow: column wrap;
  79. order: -1;
  80. }
  81. main > .leftDiv > span{
  82. flex: 1;
  83. border-bottom: 1px solid white;
  84. text-align: center;
  85. padding: 12px;
  86. }
  87. /*主体区域*/
  88. .container{
  89. box-sizing: border-box;
  90. background: -webkit-linear-gradient(bottom,lavenderblush,lightblue);
  91. display: flex;
  92. flex-flow: row wrap;
  93. flex: 1;
  94. justify-content: center;
  95. }
  96. .container > article{
  97. background-color: lightseagreen;
  98. width: 180px;
  99. height: 100px;
  100. margin-right: 25px;
  101. justify-content: center;
  102. align-content: center;
  103. margin-top: 10px;
  104. }
  105. .container > article > img{
  106. width: 60px;
  107. height: 60px;
  108. margin: 0 50px;
  109. }
  110. .container > article > p{
  111. margin: 0 50px;
  112. }
  113. .tableDiv{
  114. display: flex;
  115. }
  116. table{
  117. border: 1px solid lightgray;
  118. box-sizing: border-box;
  119. box-shadow: 1px 1px 1px #999 ;
  120. color: #444;
  121. width: 700px;
  122. margin: 20px auto;
  123. border-collapse: collapse;
  124. }
  125. th,td{
  126. border: 1px solid lightgray;
  127. text-align: center;
  128. padding: 10px;
  129. }
  130. table caption{
  131. font-size: 1.3rem;
  132. }
  133. table thead{
  134. background: linear-gradient(purple,white);
  135. }
  136. table tfoot{
  137. background: linear-gradient(yellow,white);
  138. }
  139. table tbody > tr:nth-of-type(even){
  140. background-color: #ededed;
  141. }
  142. table tbody > tr:first-of-type td:first-of-type{
  143. background: radial-gradient(orange, white);
  144. }
  145. table tbody > tr:nth-last-child(3) td:first-of-type{
  146. background-color: olive;
  147. }
  148. table tfoot > tr:last-of-type td:last-of-type{
  149. background-color: linen;
  150. }

运行效果

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议