博客列表 >HTML的表格和表单

HTML的表格和表单

BARRY
BARRY原创
2020年08月09日 19:14:46449浏览

表格(房源详情表)

  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. thead {
  9. background-color: chartreuse;
  10. }
  11. tbody {
  12. background-color: yellow;
  13. }
  14. tfoot {
  15. background-color: gainsboro;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <!-- 表格 -->
  21. <table border="1" cellspacing="0" cellpading="8" width="600px">
  22. <!-- 标题 -->
  23. <caption>
  24. 房源详情表
  25. </caption>
  26. <!-- 表头 -->
  27. <thead>
  28. <tr>
  29. <th colspan="2">房源编号:</th>
  30. <td colspan="2">HS20200731</td>
  31. </tr>
  32. </thead>
  33. <!-- 主体 -->
  34. <tbody>
  35. <tr>
  36. <th colspan="2">房源标题:</th>
  37. <td colspan="2">独家房源!仅此一套!错过了就没有了</td>
  38. </tr>
  39. <tr>
  40. <th>户型:</th>
  41. <td>三室一厅</td>
  42. <th rowspan="2">面积:</th>
  43. <td rowspan="2">120平方米</td>
  44. </tr>
  45. <tr>
  46. <th>年代:</th>
  47. <td>2010年</td>
  48. </tr>
  49. <tr>
  50. <th>装修:</th>
  51. <td>豪华装修</td>
  52. <th>佣金:</th>
  53. <td>5%</td>
  54. </tr>
  55. <tr>
  56. <th>业主:</th>
  57. <td colspan="3">张三,联系方式18866667777</td>
  58. </tr>
  59. </tbody>
  60. <!-- 底部 -->
  61. <tfoot>
  62. <tr>
  63. <th>房源描述</th>
  64. <td colspan="3">
  65. 南北通透,全天采光好,透气好,地理位置优越,配套设施一应俱全
  66. </td>
  67. </tr>
  68. </tfoot>
  69. </table>
  70. </body>
  71. </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>表单</title>
  7. </head>
  8. <body>
  9. <h2>用户注册表</h2>
  10. <form action="">
  11. <div>
  12. <label for="username">用户名:</label>
  13. <input
  14. id="username"
  15. type="text"
  16. name="username"
  17. value=""
  18. placeholder="请输入用户名"
  19. required
  20. autofocus
  21. />
  22. </div>
  23. <div>
  24. <label for="password">密码:</label>
  25. <input
  26. type="password"
  27. id="password"
  28. name="password"
  29. value=""
  30. placeholder="密码不少于8位字符"
  31. required
  32. />
  33. </div>
  34. <div>
  35. <label for="secret">性别:</label>
  36. <input type="radio" name="sex" id="nan" /><label for="nan"></label>
  37. <input type="radio" name="sex" id="nv" /><label for="nv"></label>
  38. <input type="radio" name="sex" id="secret" /><label for="secret"
  39. >保密</label
  40. >
  41. </div>
  42. <div>
  43. <label for="">爱好</label>
  44. <input type="checkbox" name="hobby[]" id="code" /><label for="code"
  45. >敲代码</label
  46. >
  47. <input type="checkbox" name="hobby[]" id="game" /><label for="game"
  48. >打游戏</label
  49. >
  50. <input type="checkbox" name="hobby[]" id="run" /><label for="run"
  51. >跑步</label
  52. >
  53. <input type="checkbox" name="hobby[]" id="music" /><label for="music"
  54. >听音乐</label
  55. >
  56. </div>
  57. <div>
  58. <label for="user_img">头像:</label>
  59. <input type="file" name="user_img" id="user_img" />
  60. <input type="hidden" name="MAX_FILE_SIZE" value="8388608" />
  61. <input type="hidden" name="user_id" value="1010" />
  62. </div>
  63. <div>
  64. <label for="my_course">课程:</label>
  65. <input type="text" id="my_course" list="course" />
  66. <datalist id="course">
  67. <option value="html">html</option>
  68. <option value="css">css</option>
  69. <option value="javascript">javascript</option>
  70. <option value="php">php</option>
  71. <option value="java">java</option>
  72. <option value="pathon">pathon</option>
  73. </datalist>
  74. </div>
  75. <div>
  76. <label for="email">邮箱:</label>
  77. <input type="email" name="email" placeholder="demo@123.com" />
  78. </div>
  79. <div>
  80. <label for="btithday">生日:</label>
  81. <input type="date" name="btithday" />
  82. </div>
  83. <div>
  84. <label for="age">年龄:</label>
  85. <input id="age" type="number" name="age" min="18" max="50" />
  86. </div>
  87. <div>
  88. <label for="education">学历:</label>
  89. <select name="edu" id="">
  90. <option value="">请选择学历</option>
  91. <option value="gaozhong">高中</option>
  92. <option value="dazhuang">大专</option>
  93. <option value="benke">本科</option>
  94. </select>
  95. </div>
  96. <hr />
  97. <button>提交</button>
  98. </form>
  99. </body>
  100. </html>

运行结果
用户注册表

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