博客列表 >表格、表单

表格、表单

乐作人生
乐作人生原创
2020年08月11日 00:11:59603浏览
  1. 表格
    1. <!-- 表格容器 -->
    2. <!-- cellspacing:表格间距;cellpadding:表格内边距; -->
    3. <table border="1" cellspacing="0" cellpadding="15" width="500px">
    4. <!-- 表格的每一列,未设置的不能删除,列的占位符 -->
    5. <col />
    6. <col bgcolor="red" span="2" />
    7. <col />
    8. <col />
    9. <!-- 表格标题 -->
    10. <caption>
    11. 学生成绩
    12. </caption>
    13. <!-- 表格表头 -->
    14. <thead>
    15. <th>学号</th>
    16. <th>姓名</th>
    17. <th>班级</th>
    18. <th>成绩</th>
    19. </thead>
    20. <!-- 表格主体 -->
    21. <tbody>
    22. <tr>
    23. <td>20201010</td>
    24. <td>陈一</td>
    25. <!-- 表格垂直方向合并 -->
    26. <td rowspan="2">一年级2班</td>
    27. <td>96</td>
    28. </tr>
    29. <tr>
    30. <td>20201021</td>
    31. <td>王二</td>
    32. <td>87</td>
    33. </tr>
    34. <tr>
    35. <td>20201042</td>
    36. <td>张三</td>
    37. <td>一年级5班</td>
    38. <td>93</td>
    39. </tr>
    40. <tr>
    41. <td>20201013</td>
    42. <td>李四</td>
    43. <td>一年级3班</td>
    44. <td>76</td>
    45. </tr>
    46. </tbody>
    47. <!-- 表格底部 -->
    48. <tfoot>
    49. <tr>
    50. <!-- 表格水平方向合并 -->
    51. <td colspan="3" style="font-weight: 700; text-align: center;">
    52. 总成绩
    53. </td>
    54. <td>352</td>
    55. </tr>
    56. </tfoot>
    57. </table>
    58. <hr />
  2. 表单,表单域分组
    1. <!-- 表单元素,表单的内部元素称为控件元素 -->
    2. <form>
    3. <h4>会员信息</h4>
    4. <fieldset>
    5. <legend>基本信息(必填)</legend>
    6. <div style="margin: 10px 0;">
    7. <lable for="user_name">用户名:</lable>
    8. <!-- label的for值与input的id值一样,表示绑定;type="text"表示文本框,type="submit"表示提交; -->
    9. <!-- name表示当前文本框对应的变量名,name值不能出现连接符“-”,可使用下划线“_”;value表示默认值,value值会覆盖掉placeholder的值;placeholder表示给用户的提示信息; -->
    10. <!-- required表示必填项;autofocus表示自动获取焦点,但当只有一个表单控件时不写; -->
    11. <input
    12. id="user_name"
    13. type="text"
    14. name="userName"
    15. value=""
    16. placeholder="不少于2个字符"
    17. required
    18. autofocus
    19. />
    20. </div>
    21. <div style="margin: 10px 0;">
    22. <label for="pwd">密码:</label>
    23. <!-- type="password"表示密码; -->
    24. <input
    25. id="pwd"
    26. type="password"
    27. name="pass_word"
    28. value=""
    29. placceholder="不少于10个字符"
    30. required
    31. />
    32. </div>
    33. <div style="margin: 10px 0;">
    34. <label for="my-email">邮箱:</label>
    35. <input type="email" name="email" placeholder="123456.@qq.com" />
    36. </div>
    37. <div style="margin: 10px 0;">
    38. <label for="secret">性别:</label>
    39. <!-- type="radio"表示单选按钮;单选按钮的每一个选项按钮的name属性值必须一样;checked表示默认选中状态 -->
    40. <input id="" type="radio" name="gender" id="male" /><label for="male"
    41. ></label
    42. >
    43. <input id="" type="radio" name="gender" id="female" /><label
    44. for="female"
    45. ></label
    46. >
    47. <input id="" type="radio" name="gender" id="secret" checked /><label
    48. for="secret"
    49. >保密</label
    50. >
    51. </div>
    52. <div style="margin: 10px 0;">
    53. <label for="">爱好:</label>
    54. <!-- 复选框会返回多个值,name的属性值应该使用数组形式;每一个复选框后的label的for值与其前面的input的id值保持一致 -->
    55. <input type="checkbox" name="hobby[]" id="programe" /><label
    56. for="programe"
    57. >编程</label
    58. >
    59. <input type="checkbox" name="hobby[]" id="game" /><label for="game"
    60. >游戏</label
    61. >
    62. <input type="checkbox" name="hobby[]" id="travel" /><label
    63. for="travel"
    64. >旅游</label
    65. >
    66. <input type="checkbox" name="hobby[]" id="read" /><label for="read"
    67. >阅读</label
    68. >
    69. </div>
    70. <div style="margin: 10px 0;">
    71. <label for="user-img">头像</label>
    72. <input type="file" name="user_img" id="user-img" />
    73. <!-- 上传图片时可限制文件大小,用隐藏域填写,但这个数据是给服务器做参考的,不需要也不允许用户提供 -->
    74. <!-- 1k=1024byte,1m=1024k,1G=1024M,1T=1024G -->
    75. <!-- 限制上传文件的大小如8M;value值是以字节为单位的;name值为最大的_文件上传_尺寸,表示上传文件的最大尺寸; -->
    76. <input type="hidden" name="MAX_FILE_SIZE" value="8388608" />
    77. <!-- 用户id一般也是通过隐藏域发送到服务器 -->
    78. <input type="hidden" name="user_id" value="111" />
    79. </div>
    80. <div style="margin: 10px 0;">
    81. <!-- label的for值与input的id值绑定 -->
    82. <label for="my-course">课程:</label>
    83. <!-- input的list值与detalist的id值绑定 -->
    84. <input id="my-course" type="text" list="course" />
    85. <datalist id="course">
    86. <option value="html5">html5</option>
    87. <option value="css3">css3</option>
    88. <option value="js">js</option>
    89. <option value="php">php</option>
    90. </datalist>
    91. </div>
    92. </fieldset>
    93. <!-- fieldset表示表单控件分组 -->
    94. <fieldset style="margin: 20px 0;">
    95. <legend>其它信息(选填)</legend>
    96. <div style="margin: 10px 0;">
    97. <label for="my-birthday">生日:</label>
    98. <input type="date" name="birthday" />
    99. </div>
    100. <div style="margin: 10px 0;">
    101. <label for="my-age">年龄:</label>
    102. <!-- min表示最小18,max表示最大65,step表示每次递增5 -->
    103. <input type="number" name="age" min="18" max="65" step="5" />
    104. </div>
    105. <div style="margin: 10px 0;">
    106. <label for="my-color">调色板:</label>
    107. <input type="color" name="pick_color" />
    108. </div>
    109. <div style="margin: 10px 0;">
    110. <label for="">所在城市</label>
    111. <select name="city" id="">
    112. <option value="北京">北京</option>
    113. <!-- selected表示默认选项 -->
    114. <option value="河北省" selected>河北省</option>
    115. <option value="山东省">山东省</option>
    116. <option value="云南省">云南省</option>
    117. <option value="山西省">山西省</option>
    118. <option value="重庆市">重庆市</option>
    119. </select>
    120. </div>
    121. <div style="margin: 10px 0;">
    122. <!-- size="7"表示当前有7个选项;multiple表示多选,按住ctrl进行多选 -->
    123. <!-- 事件属性:用on开始跟一个事件名称,它的值是js表达式。事件改变时弹出option对应的值 -->
    124. <select name="edu" id="" onchange="alert(this.value)">
    125. <option value="">--学历--</option>
    126. <option value="小学">小学</option>
    127. <option value="初中">初中</option>
    128. <option value="高中">高中</option>
    129. <option value="大学">大学</option>
    130. <option value="研究生">研究生</option>
    131. </select>
    132. </div>
    133. </fieldset>
    134. <div style="margin: 10px 0;">
    135. <!-- 内联框架:frameborder边框 -->
    136. <iframe
    137. src="https://j.map.baidu.com/f2/wyj"
    138. frameborder="1"
    139. width="600"
    140. height="500"
    141. ></iframe>
    142. </div>
    143. <div style="margin: 10px 0;">
    144. <!-- iframe实现网站后台的原理 -->
    145. <ul>
    146. <li><a href="1.html" target="content">系统设置</a></li>
    147. <li><a href="" target="content">商品管理</a></li>
    148. <li><a href="" target="content">分类管理</a></li>
    149. </ul>
    150. <iframe
    151. srcdoc="<h3>网站后台</h3>"
    152. frameborder="1"
    153. name="content"
    154. width="600"
    155. height="500"
    156. ></iframe>
    157. </div>
    158. <button>提交</button>
    159. </form>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议