博客列表 >Chapter5 表格与表单

Chapter5 表格与表单

无关
无关原创
2020年06月26日 23:21:52590浏览

一、表格:超市购物清单

1、效果图:

2、源码

  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:80%;
  12. /* auto:左右居中 */
  13. margin:auto;
  14. color:black;
  15. background-color: lightgreen;
  16. }
  17. /* 表格样式: */
  18. table thead th,
  19. table td{
  20. /* 表格去掉上,右,左边线,只留底线:border-bottom: */
  21. border-bottom:1px solid violet;
  22. padding: 10px;
  23. }
  24. /* 标题样式: */
  25. table caption{
  26. font-size:1.3rem;
  27. margin-bottom:10px;
  28. color:blue;
  29. }
  30. table th{
  31. /* 首行字体本身是粗体,变成细体如下: */
  32. font-weight:lighter;
  33. color:red;
  34. background-color: lightblue;
  35. }
  36. /* 隔行变色 ,even:偶数行,奇数:odd*/
  37. table tbody tr:nth-of-type(odd){
  38. background-color: pink;
  39. color:brown;
  40. font-size: 1rem;
  41. }
  42. table tbody tr:nth-of-type(even) {
  43. background-color: lime;
  44. color:blue;
  45. font-size: 0.8rem;
  46. }
  47. /* 鼠标悬停效果 */
  48. table tbody tr:hover{
  49. background-color: yellow;
  50. }
  51. /* 表尾单元格样式 */
  52. table tfoot td{
  53. border-bottom: none;
  54. color:red;
  55. font-size: 1.4rem;
  56. /* 字体加粗 */
  57. font-weight:bolder;
  58. }
  59. /* 结算样式 */
  60. div:first-of-type{
  61. /* div:first-of-type也是div:last-of-type */
  62. width:80%;
  63. margin:10px auto;
  64. /* color:coral; */
  65. background-color: darkgoldenrod;
  66. }
  67. div:first-of-type button{
  68. float:right;
  69. width:120px;
  70. height:32px;
  71. background-color:lightblue;
  72. /* 去掉按钮框线 */
  73. border:none;
  74. /* 设置鼠标样式,鼠标移到按钮上时变成手 */
  75. cursor:pointer;
  76. }
  77. div:first-of-type button:hover{
  78. background-color:coral;
  79. font-size: 1.2rem;
  80. font-weight:bolder;
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <!-- 表单结构 -->
  86. <!-- <table>
  87. 表头:
  88. <thead>
  89. <tr>
  90. <th></th>
  91. <th></th>
  92. </tr>
  93. </thead>
  94. 主体:
  95. <tbody>
  96. <tr>
  97. <td></td>
  98. <td></td>
  99. </tr>
  100. </tbody>
  101. 表尾:
  102. <tfoot>
  103. <tr>
  104. <td></td>
  105. </tr>
  106. </tfoot>
  107. </table> -->
  108. <table>
  109. <caption><h2>超市购物清单</h2></caption>
  110. <!-- tr-行,td-列,th-首行加粗+居中 -->
  111. <thead>
  112. <tr>
  113. <!-- th*7 -->
  114. <th>产品编号</th>
  115. <th>名称</th>
  116. <th>单位</th>
  117. <th>单价</th>
  118. <th>优惠价</th>
  119. <th>数量</th>
  120. <th>金额</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124. <tr>
  125. <td>sp0001</td>
  126. <td>馒头</td>
  127. <td></td>
  128. <td>0.55</td>
  129. <td>0.5</td>
  130. <td>10</td>
  131. <td>5.00</td>
  132. </tr>
  133. <tr>
  134. <td>hs0050</td>
  135. <td>大闸蟹</td>
  136. <td></td>
  137. <td>65.55</td>
  138. <td>60.00</td>
  139. <td>5</td>
  140. <td>300.00</td>
  141. </tr>
  142. <tr>
  143. <td>sp0005</td>
  144. <td>肉粽</td>
  145. <td></td>
  146. <td>3.55</td>
  147. <td>3.00</td>
  148. <td>10</td>
  149. <td>30.00</td>
  150. </tr>
  151. <tr>
  152. <td>bg0010</td>
  153. <td>计算器</td>
  154. <td></td>
  155. <td>19.55</td>
  156. <td>19</td>
  157. <td>1</td>
  158. <td>19.00</td>
  159. </tr>
  160. <tr>
  161. <td>xx0001</td>
  162. <td>A4横线本</td>
  163. <td></td>
  164. <td>4.55</td>
  165. <td>4.00</td>
  166. <td>5</td>
  167. <td>20.00</td>
  168. </tr>
  169. </tbody>
  170. <tfoot>
  171. <tr>
  172. <!-- column span=colspan -->
  173. <td colspan="4"> 总计 </td>
  174. <td>13</td>
  175. <td>374.00</td>
  176. </tr>
  177. </tfoot>
  178. </table >
  179. <!-- 结算按钮 -->
  180. <div>
  181. <button>结算</button>
  182. </div>
  183. </body>
  184. </html>

二、表格:个人简历

1、部分效果图:

2、网页链接:

个人简历

3、源码:

  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. body {
  9. color:blue;
  10. }
  11. h2 {
  12. text-align: center;
  13. }
  14. form {
  15. width: 700px;
  16. margin: 30px auto;
  17. border-top: 5px solid blue;
  18. }
  19. form fieldset {
  20. border: 1px solid rgb(186, 233, 16);
  21. background-color: lightcyan;
  22. box-shadow: 20px 20px 20px rgb(189, 96, 173);
  23. /* 边框四角圆形弧度 */
  24. border-radius: 20px;
  25. margin: 40px;
  26. /* margin: 0px;比较效果差 */
  27. }
  28. form fieldset legend {
  29. background-color: rgb(178, 231, 201);
  30. border-radius: 10px;
  31. color: seagreen;
  32. padding: 5px 15px;
  33. }
  34. form div {
  35. margin: 5px;
  36. }
  37. form p {
  38. text-align: center;
  39. }
  40. form .btn {
  41. font-size: 1.2rem;
  42. width: 100px;
  43. height: 40px;
  44. border: none;
  45. background-color: seagreen;
  46. color: #ddd;
  47. }
  48. form .btn:hover {
  49. background-color: coral;
  50. color: blue;
  51. cursor: pointer;
  52. }
  53. input:focus {
  54. background-color: rgb(39, 214, 62);
  55. }
  56. </style>
  57. </head>
  58. <body>
  59. <h2>个人简历</h2>
  60. <form action="" method="POST">
  61. <fieldset>
  62. <legend>基本信息(必填)</legend>
  63. <div>
  64. <label for="myname">姓名:</label>
  65. <input
  66. type="text"
  67. id="myname"
  68. name="name"
  69. placeholder="6-15位字符"
  70. autofocus
  71. required
  72. />
  73. </div>
  74. <div>
  75. <label for="secret">性别:</label>
  76. <input
  77. type="radio"
  78. name="gender"
  79. value="male"
  80. id="male"/>
  81. <label for="male">man</label>
  82. <input
  83. type="radio"
  84. name="gender"
  85. value="female"
  86. id="female"/>
  87. <label for="female">woman</label>
  88. <input
  89. type="radio"
  90. name="gender"
  91. value="secret"
  92. id="secret"
  93. checked
  94. />
  95. <label for="secret">保密</label>
  96. </div>
  97. <div>
  98. <label for="age">年龄:</label>
  99. <input
  100. type="text"
  101. id="age"
  102. name="age"
  103. placeholder="2-8位字符"
  104. autofocus
  105. required
  106. />
  107. </div>
  108. <div>
  109. <label for="cellphone">手机:</label>
  110. <input
  111. type="text"
  112. id="cellphone"
  113. name="phone"
  114. placeholder="11位字符"
  115. autofocus
  116. required
  117. />
  118. </div>
  119. <div>
  120. <label for="">邮箱:</label>
  121. <input
  122. type="email"
  123. name="email"
  124. id="email-id"
  125. placeholder="demo@example.com"
  126. required
  127. />
  128. </div>
  129. <div>
  130. <label for="education">学历:</label>
  131. <input
  132. type="text"
  133. id="education"
  134. name="education"
  135. placeholder="6-15位字符"
  136. autofocus
  137. required
  138. />
  139. </div>
  140. <div>
  141. <label for="college">毕业学校:</label>
  142. <input
  143. type="text"
  144. id="college"
  145. name="college"
  146. placeholder="6-30位字符"
  147. autofocus
  148. required
  149. />
  150. </div>
  151. <div>
  152. <label for="main courses">专业:</label>
  153. <input
  154. type="text"
  155. id="main courses"
  156. name="main courses"
  157. placeholder="6-30位字符"
  158. autofocus
  159. required
  160. />
  161. </div>
  162. <div>
  163. <label for="language">语言:</label>
  164. <input type="checkbox" name="language[]" id="chinese"
  165. value="chinese"
  166. /> <label for="chinese" >中文</label >
  167. <input
  168. type="checkbox"
  169. name="language[]"
  170. value="english"
  171. id="english"
  172. /><label for="english">英语</label>
  173. <input
  174. type="checkbox"
  175. name="language[]"
  176. value="japanses"
  177. id="japanses"
  178. /><label for="japanses">日语</label>
  179. </div>
  180. <div>
  181. <label for="uploads">1寸头照:</label>
  182. <input type="file" name="pic" id="uploads" accept="image/png, image/jpeg,image/gif" />
  183. </div>
  184. </fieldset>
  185. <fieldset>
  186. <legend>扩展信息(必填)</legend>
  187. <div>
  188. <label for="Study resume">学习简历:</label>
  189. <hr>
  190. <textarea name="study" id="Study resume" cols="80" rows="5" placeholder="不超过200字">
  191. </textarea>
  192. </div>
  193. <div>
  194. <label for="work experience">工作简历:</label>
  195. <hr>
  196. <textarea name="work" id="work experience" cols="80" rows="5" placeholder="不超过200字">
  197. </textarea>
  198. </div>
  199. <label for="training">培训简历:</label>
  200. <hr>
  201. <textarea name="training" id="training" cols="80" rows="5" placeholder="不超过200字">
  202. </textarea>
  203. <div>
  204. <label for="Certificate">资格证:</label>
  205. <hr>
  206. <textarea name="Certificate" id="Certificate" cols="80" rows="5" placeholder="不超过200字">
  207. </textarea>
  208. </div>
  209. <div>
  210. <label for="skills">技能获得:</label>
  211. <hr>
  212. <textarea name="skills" id="skills" cols="80" rows="5" placeholder="不超过200字">
  213. </textarea>
  214. </div>
  215. </fieldset>
  216. <fieldset>
  217. <legend>其他信息(选填)</legend>
  218. <div>
  219. <label for="hobby">爱好:</label>
  220. <input type="checkbox" name="hobby[]" id="moive"
  221. value="moive"
  222. /> <label for="moive" >看电影</label >
  223. <input
  224. type="checkbox"
  225. name="hobby[]"
  226. value="shoot"
  227. id="shoot"
  228. /><label for="shoot">摄影</label>
  229. <input
  230. type="checkbox"
  231. name="hobby[]"
  232. value="jogging"
  233. id="jogging"
  234. /><label for="jogging">慢跑</label>
  235. <input
  236. type="checkbox"
  237. name="hobby[]"
  238. value="travel"
  239. id="travel"
  240. /><label for="travel">旅行</label >
  241. </div>
  242. <div>
  243. <label for="constellation">星座:</label>
  244. <input
  245. type="text"
  246. id="constellation"
  247. name="constellation"
  248. placeholder="6-15位字符"
  249. autofocus
  250. required
  251. />
  252. </div>
  253. <div>
  254. <label for="Btype">血型:</label>
  255. <input type="checkbox" name="Btype[]" id="A"
  256. value="A"
  257. /> <label for="B" >A</label >
  258. <input
  259. type="checkbox"
  260. name="Btype[]"
  261. value="B"
  262. id="B"
  263. /><label for="B">B</label>
  264. <input
  265. type="checkbox"
  266. name="Btype[]"
  267. value="O"
  268. id="O"
  269. /><label for="O">O</label>
  270. </div>
  271. <div>
  272. <label for="awards">获奖:</label>
  273. <hr>
  274. <textarea name="skills" id="skills" cols="80" rows="5" placeholder="不超过200字">
  275. </textarea>
  276. </div>
  277. <div>
  278. <label for="schoolarships">奖学金:</label>
  279. <hr>
  280. <textarea name="skills" id="skills" cols="80" rows="5" placeholder="不超过200字">
  281. </textarea>
  282. </div>
  283. <div>
  284. <label for=" Self-evaluation">自我评价:</label>
  285. <hr>
  286. <textarea name="Self-evaluation" id="Self-evaluation" cols="80" rows="5" placeholder="不超过200字">
  287. </textarea>
  288. </div>
  289. </fieldset>
  290. <p>
  291. <button class="btn">提交</button>
  292. </p>
  293. </form>
  294. </body>
  295. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议
2020-06-26 23:13:411楼
哈哈,表单的图太大,一屏截不下,就直接用链接了。一会儿加个图。 购物车配色故意搞得狠辣,眼睛表示这样更容易博眼球。一眼能瞅出不同属性配置的色效,不朦胧。 谢谢老师!