Blogger Information
Blog 5
fans 0
comment 0
visits 4972
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
html表格与表单实战
逝去
Original
937 people have browsed it

一、html 表格实战

制作一张课程表,或者商品列表,用户信息表,要求用到行与列的合并。

实现效果图:

1表格实战-课程表


实现代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>作业:课程表</title>
  8. </head>
  9. <body>
  10. <table
  11. width="50%"
  12. align="center"
  13. border="1px"
  14. cellpadding="5"
  15. cellspacing="0"
  16. >
  17. <caption>
  18. <h3>合肥市第一小学六(六)班课程表</h3>
  19. </caption>
  20. <thead>
  21. <tr bgcolor="lightcyan">
  22. <!-- th:是添加了加粗和居中样式的td,td的加强版,适合做表头标题 -->
  23. <th colspan="2">时间</th>
  24. <th>星期一</th>
  25. <th>星期二</th>
  26. <th>星期三</th>
  27. <th>星期四</th>
  28. <th>星期五</th>
  29. </tr>
  30. </thead>
  31. <!-- 表主体1:上午四节课 -->
  32. <tbody align="center">
  33. <tr>
  34. <td rowspan="4" bgcolor="lightblue" style="font-weight: bold">
  35. 上午
  36. </td>
  37. <td>1</td>
  38. <td>数学</td>
  39. <td>数学</td>
  40. <td>语文</td>
  41. <td>英语</td>
  42. <td>数学</td>
  43. </tr>
  44. <tr>
  45. <td>2</td>
  46. <td>体育</td>
  47. <td>语文</td>
  48. <td>数学</td>
  49. <td>数学</td>
  50. <td>英语</td>
  51. </tr>
  52. <tr>
  53. <td>3</td>
  54. <td>语文</td>
  55. <td>美术</td>
  56. <td>英语</td>
  57. <td>语文</td>
  58. <td>美术</td>
  59. </tr>
  60. <tr>
  61. <td>4</td>
  62. <td>语文</td>
  63. <td>思维</td>
  64. <td>外教</td>
  65. <td>体育</td>
  66. <td>体育</td>
  67. </tr>
  68. </tbody>
  69. <!-- 表主体2:中午休息 -->
  70. <tbody align="center">
  71. <tr bgcolor="lightgray">
  72. <td colspan="7">中午休息</td>
  73. </tr>
  74. </tbody>
  75. <!-- 表主体3:下午三节课。与上午课程类似 -->
  76. <tbody align="center">
  77. <tr>
  78. <td rowspan="3" bgcolor="lightblue" style="font-weight: bold">
  79. 下午
  80. </td>
  81. <td>5</td>
  82. <td>外教</td>
  83. <td>体育</td>
  84. <td>语文</td>
  85. <td>音乐</td>
  86. <td>语文</td>
  87. </tr>
  88. <tr>
  89. <td>6</td>
  90. <td>音乐</td>
  91. <td>品德</td>
  92. <td>阅读</td>
  93. <td>品德</td>
  94. <td>语文</td>
  95. </tr>
  96. <tr>
  97. <td>7</td>
  98. <td>课外活动</td>
  99. <td>课外活动</td>
  100. <td>课外活动</td>
  101. <td>课外活动</td>
  102. <td>课外活动</td>
  103. </tr>
  104. </tbody>
  105. <!-- 表尾:底部备注 -->
  106. <tfoot>
  107. <tr bgcolor="lightgreen">
  108. <td>备注:</td>
  109. <!-- 从第2列开始水平合并6列 -->
  110. <td colspan="6">每天下午17:00~18:00写完作业再回家</td>
  111. </tr>
  112. </tfoot>
  113. </table>
  114. </body>
  115. </html>

二、html 表单实战

制作一张用户注册表单,要求用到常用的表单控件。

实现效果图:

2表单实战-注册表单


实现代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>作业:用户注册表单</title>
  8. </head>
  9. <body>
  10. <form action="" style="display: grid; gap: 0.5em; width: 25%" method="POST">
  11. <fieldset>
  12. <legend>必填项</legend>
  13. <div>
  14. <label for="account">账号:</label>
  15. <input
  16. type="text"
  17. id="account"
  18. autofocus
  19. required
  20. placeholder="5~20个字符,字母或汉字"
  21. />*
  22. </div>
  23. <div>
  24. <label for="password">密码:</label>
  25. <input
  26. type="password"
  27. id="password"
  28. required
  29. placeholder="6~20个字符,字母+数字"
  30. />*
  31. </div>
  32. <div>
  33. <label for="email">邮箱:</label>
  34. <input
  35. type="email"
  36. name="email"
  37. id="email"
  38. required
  39. placeholder="demo@mail.com"
  40. />*
  41. </div>
  42. </fieldset>
  43. <div style="margin-left: 5%">
  44. <label for="secret">性别:</label>
  45. <input type="radio" name="gender" value="male" id="male" /><label
  46. for="male"
  47. ></label
  48. >
  49. <input type="radio" name="gender" value="female" id="female" /><label
  50. for="female"
  51. ></label
  52. >
  53. <input
  54. type="radio"
  55. name="gender"
  56. value="secret"
  57. id="secret"
  58. checked
  59. /><label for="secret">保密</label>
  60. </div>
  61. <div style="margin-left: 5%">
  62. <label>爱好:</label>
  63. <input type="checkbox" name="hobby[]" id="programmer" checked /><label
  64. for="programmer"
  65. >编程</label
  66. >
  67. <input type="checkbox" name="hobby[]" id="game" /><label for="game"
  68. >游戏</label
  69. >
  70. <input type="checkbox" name="hobby[]" id="sport" checked /><label
  71. for="sport"
  72. >运动</label
  73. >
  74. <input type="checkbox" name="hobby[]" id="trave" /><label for="trave"
  75. >旅游</label
  76. >
  77. </div>
  78. <div style="text-align: center">
  79. <button type="submit">提交</button>
  80. </div>
  81. </form>
  82. </body>
  83. </html>
  84. ```
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