博客列表 >HTML入门练习:我的课程表和注册(基本信息)表单

HTML入门练习:我的课程表和注册(基本信息)表单

李东亚¹⁸⁰³⁹⁵⁴⁰¹²⁰
李东亚¹⁸⁰³⁹⁵⁴⁰¹²⁰原创
2020年12月11日 17:59:00989浏览

HTML-小demo练习:我的课程表

1、我的课程表代码:

  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>我的课程表</title>
  8. <style>
  9. table{
  10. text-align: center;
  11. }
  12. table>caption{
  13. font-size: 2rem;
  14. margin-bottom: 10px;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <table border="1" cellpadding="10" cellspacing="0" align="center">
  20. <caption>我的课程表</caption>
  21. <thead>
  22. <tr>
  23. <th colspan="2"></th>
  24. <th>星期一</th>
  25. <th>星期二</th>
  26. <th>星期三</th>
  27. <th>星期四</th>
  28. <th>星期五</th>
  29. <th>星期六</th>
  30. <th>星期日</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <tr>
  35. <td rowspan="4">上午</td>
  36. <td>第一节</td>
  37. <td>HTML</td>
  38. <td>CSS</td>
  39. <td>JavaScript</td>
  40. <td>Vue</td>
  41. <td>PHP</td>
  42. <td colspan="2" rowspan="8">休息</td>
  43. </tr>
  44. <tr>
  45. <td>第二节</td>
  46. <td>HTML</td>
  47. <td>CSS</td>
  48. <td>JavaScript</td>
  49. <td>Vue</td>
  50. <td>PHP</td>
  51. </tr>
  52. <tr>
  53. <td>第三节</td>
  54. <td>HTML</td>
  55. <td>CSS</td>
  56. <td>JavaScript</td>
  57. <td>Vue</td>
  58. <td>PHP</td>
  59. </tr>
  60. <tr>
  61. <td>第四节</td>
  62. <td>HTML</td>
  63. <td>CSS</td>
  64. <td>JavaScript</td>
  65. <td>Vue</td>
  66. <td>PHP</td>
  67. </tr>
  68. <tr>
  69. <td colspan="7">午休时间:12:00-2:00</td>
  70. </tr>
  71. <tr>
  72. <td rowspan="3">下午</td>
  73. <td>第一节</td>
  74. <td>HTML</td>
  75. <td>CSS</td>
  76. <td>JavaScript</td>
  77. <td>Vue</td>
  78. <td>PHP</td>
  79. </tr>
  80. <tr>
  81. <td>第二节</td>
  82. <td>HTML</td>
  83. <td>CSS</td>
  84. <td>JavaScript</td>
  85. <td>Vue</td>
  86. <td>PHP</td>
  87. </tr>
  88. <tr>
  89. <td>第三节</td>
  90. <td>HTML</td>
  91. <td>CSS</td>
  92. <td>JavaScript</td>
  93. <td>Vue</td>
  94. <td>PHP</td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </body>
  99. </html>

2、运行效果:
我的课程表
3、表格常见标签:

  • table>caption\thead\tbody>tr>th\td
  • 表格合并的属性:rowspan\colspan=”n”
  • 表格边框:border=”n”:边框粗细 n阿拉伯数字,cellspacing=”n”:单元格和边框的间距;cellpadding=”n”:单元格内部与内容间距

HTML表单-注册小demo

1、注册表单代码:

  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>注册表单</title>
  8. <style>
  9. *{
  10. padding: 0;
  11. margin: 0;
  12. /* outline: 1px solid #FF0000; */
  13. }
  14. .register{
  15. margin: 30px auto;
  16. width: 400px;
  17. }
  18. form{
  19. padding: 10px 5px;
  20. border: 1px solid #2C3E50;
  21. display: grid;
  22. grid-template-columns: 1fr 2fr;
  23. grid-row-gap: 20px;
  24. grid-column-gap:15px ;
  25. }
  26. h2{
  27. text-align: center;
  28. margin-bottom: 10px;
  29. }
  30. form>:nth-child(2n+1):not(.btn){
  31. /* color:red; */
  32. text-align:justify;
  33. text-align-last: justify;
  34. }
  35. form .btn{
  36. grid-column-start: 2 span;
  37. margin: 0 60px;
  38. text-align: center;
  39. }
  40. form .btn button {
  41. width: 80px;
  42. margin-left: 20px;
  43. margin-right:20px
  44. }
  45. </style>
  46. </head>
  47. <body>
  48. <div class="register">
  49. <h2>用户注册</h2>
  50. <form action="" method="" enctype="application/x-www-form-urlencoded">
  51. <label for="username">账户:</label>
  52. <input type="text" name="username" id="username" value="" placeholder="请输入你的账户……" required>
  53. <label for="pwd">密码:</label>
  54. <input type="password" name="pwd" value="" id="pwd" placeholder="请输入不少于6位密码" required>
  55. <label for="age">年龄:</label>
  56. <input type="number" name="age" value="" id="age">
  57. <label for="email">邮箱:</label>
  58. <input type="email" name="email" value="" id="email" placeholder="admin@mail.com">
  59. <label for="tel">手机:</label>
  60. <input type="tel" name="tel" value="" id="tel">
  61. <label for="sex1">性别:</label>
  62. <div>
  63. <label for="sex1"></label>
  64. <input type="radio" name="sex" value="1" id="sex1">
  65. <label for="sex2"></label>
  66. <input type="radio" name="sex" value="2" id="sex2">
  67. <label for="sex3">保密</label>
  68. <input type="radio" name="sex" value="3" id="sex3" checked>
  69. </div>
  70. <label for="#">爱好:</label>
  71. <div>
  72. <input type="checkbox" name="loves[]" value="html" id="html">
  73. <label for="html">HTML</label>
  74. <input type="checkbox" name="loves[]" value="css" id="css" checked>
  75. <label for="css">css</label>
  76. <input type="checkbox" name="loves[]" value="vue" id="vue">
  77. <label for="vue">Vue</label>
  78. <input type="checkbox" name="loves[]" value="php" id="php" checked>
  79. <label for="php">PHP</label>
  80. </div>
  81. <label for="">学历:</label>
  82. <!-- <select name="edu" multiple size="2"> -->
  83. <select name="edu">
  84. <optgroup label="初级教育">
  85. <option value ="初中" >初中</option>
  86. <option value ="高中" selected>高中</option>
  87. </optgroup>
  88. <optgroup label="高等教育">
  89. <option value ="大学">大学</option>
  90. <option value ="学士">研究生</option>
  91. </optgroup>
  92. </select>
  93. <label for="userimg" >照片:</label>
  94. <div>
  95. <input type="hidden" name="MAX_FILE_SIZE" value="80000">
  96. <input type="file" name="user_img" value="" id="userimg">
  97. </div>
  98. <label for="">自我介绍:</label>
  99. <textarea rows="5" cols="10" style="resize:none;">
  100. </textarea>
  101. <div class="btn">
  102. <button type="reset">重置</button>
  103. <button type="submit">提交</button>
  104. </div>
  105. </form>
  106. </div>
  107. </body>
  108. </html>

2、运行结果效果图:
注册表单
3、表单常用标签:

  • form标签:属性(action=”url”,method=”GET|POST”,enctype=”application/x-www-form-urlencoded”)
  • input标签:type类型常见:text/password/radio/checkbox/file/mail/tel/number
  • button标签:type类型:submit/reset/
  • label标签:显示控件旁边为说明文字
  • form表单可以通过id属性和form=”form-id的值”绑定form表单以外的元素标签控件
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议