欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

购物车表格实现和用户注册页面表单实现,div实现员工信息表格

程序员文章站 2022-03-24 09:45:46
...

1.购物车表格实现

  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>表格实战:购物车</title>
  7. <style>
  8. table{
  9. /* 将单元格之间的间隙去掉 */
  10. border-collapse: collapse;
  11. width: 70%;
  12. margin: auto;
  13. color: #666;
  14. font-weight: lighter;
  15. /* text-align: center;文本居中 */
  16. text-align: center;
  17. }
  18. /* 表格线直接添加到单元格上面 */
  19. table thead th,table td{
  20. border-bottom: 1px solid #000;
  21. padding: 10px;
  22. }
  23. /* 标题样式 */
  24. table caption{
  25. font-size: 30px;
  26. margin-bottom: 15px;
  27. color: seagreen;
  28. }
  29. /* 设置标题栏字体 */
  30. table th {
  31. font-weight: lighter;
  32. color: seagreen;
  33. }
  34. /* 标题栏添加背景色 */
  35. table thead{
  36. background-color: seashell;
  37. }
  38. /* 隔行变色 */
  39. table tbody tr:nth-of-type(even){
  40. background-color: skyblue;
  41. }
  42. /* 鼠标悬停效果 */
  43. table tbody tr:hover{
  44. background-color: snow;
  45. }
  46. /* 底部样式 */
  47. table tfoot td{
  48. border-bottom: none;
  49. color: violet;
  50. font-size: 1.2rem;
  51. font-weight: bolder;
  52. }
  53. /* 结算按钮 */
  54. body div:last-of-type{
  55. width: 70%;
  56. margin: auto;
  57. }
  58. body div:first-of-type button{
  59. /* 靠右 */
  60. float: right;
  61. width: 100px;
  62. height: 32px;
  63. background-color: seagreen;
  64. color: wheat;
  65. border: none;
  66. /* 设置鼠标样式 */
  67. cursor: pointer;
  68. }
  69. /* 设置鼠标悬停效果 */
  70. body div:first-of-type button:hover{
  71. background-color: coral;
  72. font-size: 1.1rem;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <!-- 表格 -->
  78. <table>
  79. <!-- 标题 -->
  80. <caption>购物车</caption>
  81. <!-- 头部 -->
  82. <thead>
  83. <tr>
  84. <th>ID</th>
  85. <th>品牌名</th>
  86. <th>单价/元</th>
  87. <th>单位</th>
  88. <th>数量</th>
  89. <th>金额/元</th>
  90. </tr>
  91. </thead>
  92. <!-- 主体 -->
  93. <tbody>
  94. <tr>
  95. <td>SN-1010</td>
  96. <td>MacBook Pro电脑</td>
  97. <td>1888</td>
  98. <td></td>
  99. <td>1</td>
  100. <td>1888</td>
  101. </tr>
  102. <tr>
  103. <td>SN-1020</td>
  104. <td>华为 电脑</td>
  105. <td>1999</td>
  106. <td></td>
  107. <td>1</td>
  108. <td>1999</td>
  109. </tr>
  110. <tr>
  111. <td>SN-1030</td>
  112. <td>华硕电脑</td>
  113. <td>2888</td>
  114. <td></td>
  115. <td>1</td>
  116. <td>2888</td>
  117. </tr>
  118. <tr>
  119. <td>SN-1040</td>
  120. <td>戴尔电脑</td>
  121. <td>2088</td>
  122. <td></td>
  123. <td>1</td>
  124. <td>2088</td>
  125. </tr>
  126. </tbody>
  127. <!-- 底部 -->
  128. <tfoot>
  129. <tr>
  130. <!-- colspan跨列 -->
  131. <td colspan="4">总计:</td>
  132. <td>13</td>
  133. <td>12343</td>
  134. </tr>
  135. </tfoot>
  136. </table>
  137. <!-- 结算按钮 -->
  138. <div>
  139. <button>结算</button>
  140. </div>
  141. </body>
  142. </html>

购物车表格实现和用户注册页面表单实现,div实现员工信息表格

2.用户注册页面表单实现

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0" >
  6. <title>用户注册</title>
  7. <style>
  8. body {
  9. color: #555;
  10. }
  11. h3 {
  12. text-align: center;
  13. }
  14. form {
  15. width: 450px;
  16. margin: 30px auto;
  17. border-top: 1px solid #aaa;
  18. }
  19. form fieldset {
  20. border: 1px solid seagreen;
  21. background-color: lightcyan;
  22. box-shadow: 2px 2px 4px #bbb;
  23. border-radius: 10px;
  24. margin: 20px;
  25. }
  26. form fieldset legend {
  27. background-color: rgb(178, 231, 201);
  28. border-radius: 10px;
  29. color: seagreen;
  30. padding: 5px 15px;
  31. }
  32. form div {
  33. margin: 5px;
  34. }
  35. form p {
  36. text-align: center;
  37. }
  38. form .btn {
  39. width: 80px;
  40. height: 30px;
  41. border: none;
  42. background-color: seagreen;
  43. color: #ddd;
  44. }
  45. form .btn:hover {
  46. background-color: coral;
  47. color: white;
  48. cursor: pointer;
  49. }
  50. input:focus {
  51. background-color: rgb(226, 226, 175);
  52. }
  53. </style>
  54. </head>
  55. <body>
  56. <h3>用户注册</h3>
  57. <!-- form+input -->
  58. <form action="" method="POST">
  59. <!-- 控件组 -->
  60. <fieldset>
  61. <legend>基本信息(必填)</legend>
  62. <div>
  63. <label for="my-usernam">账号:</label>
  64. <input type="text"
  65. id="my-usernam"
  66. name="usernam"
  67. placeholder="6-15位字符"
  68. autofocus
  69. required
  70. >
  71. </div>
  72. <div>
  73. <label for="email-id">邮箱:</label>
  74. <input type="email"
  75. name="email"
  76. id="email-id"
  77. placeholder="demo@abc.com"
  78. required
  79. >
  80. </div>
  81. <!-- 密码 -->
  82. <div>
  83. <label for="pwd">密码:</label>
  84. <input type="password"
  85. name="password1"
  86. id="pwd"
  87. placeholder="不少于六位且字母+数字"
  88. >
  89. <button onclick="showPwd(this)" id="btn" type="button">显示密码</button>
  90. </div>
  91. <div>
  92. <label for="pwd-1">确认密码:</label>
  93. <input type="password" name="password2" id="pwd-1">
  94. </div>
  95. </fieldset>
  96. <fieldset>
  97. <legend>扩展信息(选填)</legend>
  98. <div>
  99. <label for="birthday">生日:</label>
  100. <input type="date" name="birthday" id="birthday">
  101. </div>
  102. <div>
  103. <!-- 单选按钮 -->
  104. <label for="secret">性别:</label>
  105. <!-- 单选按钮中的name属性名必须相同 -->
  106. <input type="radio" name="gender" id="male" id="male">
  107. <label for="male"></label>
  108. <input type="radio" name="gender" id="female" id="female">
  109. <label for="female"></label>
  110. <input type="radio" name="gender" id="secret" id="secret" checked>
  111. <label for="secret">保密</label>
  112. </div>
  113. <div>
  114. <!-- 复选框 -->
  115. <label for="programe">爱好</label>
  116. <!-- 复选框返回是一个或多个值,最方便后端用数组来处理,所以将name名称设置为数组形式便于后端脚本处理 -->
  117. <input type="checkbox" name="hoddy[]" id="game" value="game">
  118. <label for="game">打游戏</label>
  119. <input type="checkbox" name="hoddy[]" id="shoot" value="shoot">
  120. <label for="shoot">摄影</label>
  121. <input type="checkbox" name="hoddy[]" id="programe" value="programe" checked>
  122. <label for="programe">编程</label>
  123. </div>
  124. <div>
  125. <!-- 选项列表 -->
  126. <label for="brand">手机</label>
  127. <input type="search" name="brand" id="brand" list="phone">
  128. <datalist id="phone">
  129. <option value="apple" ></option>
  130. <option value="huawei" label="华为"></option>
  131. <option value="mi">小米</option>
  132. </datalist>
  133. </div>
  134. </fieldset>
  135. <fieldset>
  136. <legend>其他信息(选填)</legend>
  137. <!-- 文件上传 -->
  138. <div>
  139. <label for="uploads">上传头像:</label>
  140. <input type="file" name="user_pic"
  141. id="uploads" accept="image/png,image/jpeg,image/gif">
  142. </div>
  143. <div>
  144. <label for="resume">简历:</label>
  145. <!-- 注意文本域没有value属性 -->
  146. <textarea name="resume" id="resume" cols="30" rows="10"></textarea>
  147. </div>
  148. </fieldset>
  149. <!-- 隐藏域,例如用户的ID,注册,登录的时间。。。。。 -->
  150. <input type="hidden" name="user_id" value="123">
  151. <p>
  152. <input type="submit" value="提交" class="btn">
  153. <button class="btn">提交</button>
  154. </p>
  155. </form>
  156. <script>
  157. // 显示密码
  158. function showPwd(ele){
  159. // const pwd=document.querySelector("#pwd").type="text";
  160. const pwd=document.querySelector("#pwd");
  161. pwd.type="text"
  162. }
  163. </script>
  164. </body>
  165. </html>

购物车表格实现和用户注册页面表单实现,div实现员工信息表格

3.div实现员工信息表格

  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>div实现员工信息表</title>
  7. <style>
  8. /* 表格 */
  9. .table{
  10. /* display: 规定元素应该生成的框的类型 */
  11. display: table;
  12. border: 1px solid #000;
  13. width: 300px;
  14. text-align: center;
  15. margin: auto;
  16. }
  17. /* 标题 */
  18. .table-caption{
  19. display: table-caption;
  20. margin-bottom: 10px;
  21. font-size: 1.4rem;
  22. }
  23. /* 表头 */
  24. .table-thead{
  25. display: table-header-group;
  26. background-color: darkcyan;
  27. }
  28. /* 行 */
  29. .table-row{
  30. display: table-row;
  31. }
  32. /* 列 */
  33. .table-cell{
  34. display: table-cell;
  35. border: 1px solid #000;
  36. padding: 5px;
  37. }
  38. /* 主体 */
  39. .table-tbody{
  40. display: table-row-group;
  41. }
  42. /* 底部 */
  43. .table-tfoot{
  44. display: table-footer-group;
  45. }
  46. /* 列分组table-colgroup */
  47. .table-colgroup{
  48. display: table-column-group;
  49. }
  50. /* 第一列 */
  51. .table-colgroup .table-col:first-of-type{
  52. display: table-column;
  53. background-color: darkgray;
  54. }
  55. /* 其他列 */
  56. .table-colgroup .table-col{
  57. display: table-column;
  58. background-color:darksalmon;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <!-- 表格:<table> -->
  64. <div class="table">
  65. <div class="table-caption">员工信息表</div>
  66. <!-- 列分组<colgroup> -->
  67. <div class="table-colgroup">
  68. <div class="table-col"></div>
  69. <div class="table-col"></div>
  70. <div class="table-col"></div>
  71. </div>
  72. <!-- 表头:<thead> -->
  73. <div class="table-thead">
  74. <div class="table-row">
  75. <div class="table-cell">ID</div>
  76. <div class="table-cell">姓名</div>
  77. <div class="table-cell">职务</div>
  78. </div>
  79. </div>
  80. <!-- 主体 -->
  81. <div class="table-tbody">
  82. <div class="table-row">
  83. <div class="table-cell">1</div>
  84. <div class="table-cell">康师傅</div>
  85. <div class="table-cell">拉面</div>
  86. </div>
  87. </div>
  88. <div class="table-tbody">
  89. <div class="table-row">
  90. <div class="table-cell">2</div>
  91. <div class="table-cell">程序猿</div>
  92. <div class="table-cell">IT</div>
  93. </div>
  94. </div>
  95. <div class="table-tbody">
  96. <div class="table-row">
  97. <div class="table-cell">2</div>
  98. <div class="table-cell">码农</div>
  99. <div class="table-cell">小农农</div>
  100. </div>
  101. </div>
  102. <!-- 底部:<tfoot> -->
  103. <div class="table-tfoot">
  104. <div class="table-row">
  105. <div class="table-cell">ds</div>
  106. <div class="table-cell">bs</div>
  107. <div class="table-cell">cs</div>
  108. </div>
  109. </div>
  110. </div>
  111. </body>
  112. </html>

购物车表格实现和用户注册页面表单实现,div实现员工信息表格