博客列表 >05 table表格,form表单

05 table表格,form表单

老黑
老黑原创
2020年06月18日 22:12:361067浏览

表格的主要内容

  • ① 通过table来做表格,也可以通过div来做表格。
  • 表格的元素挺多,相对繁杂的地方在于表格的装饰这块。
  • ② 通过div来建立表格:将每个div通过css中的display属性显示成对应的表格元素。

表单的主要内容

  • ① form中可以使用下fieldset,将同一类信息汇总到一些。通过legend加上这块的标题。
  • ② 表单中的input种类选择包括了文本、数字、单选、复选(checkbox)、图片上传、大文本。表单即问卷。可以用来做问卷设计了。
  • ③ 每个字段(录入框)可以放到一个div中。这样就不用<br>再去分行。
  • ④ 每个录入框前面的文字说明,最好用label,而且通过for来跟具体的input id绑定。
  • ⑤ 绑定了input id的label,如果有focus或默认功能,鼠标点到label时,鼠标会自动锁定到锁定过去。
  • ⑥ input有一个类型为hidden的,即不显示出来,例如填写的日期时间等可以自动获得的,就可以直接通过这种带过去。
  • ⑦ 密码的临时显示可以通过将input的type从password改为text的方式进行显示。需要用到前面学习的js获取及属性改变的功能。

1、表格及表格的基本元素

a-表格是什么?

表格: 数据格式化的工具

b-完整的表格涉及9个标签/元素:

table + caption + colgroup + thead + tbody + tfoot + tr + th + td

常用的:
table + caption + thead + tbody + tr + th + td

简化的: table + caption + tbody + tr + th/td

2、魔法商场购物栏

具体code见下面:

  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. html{
  9. font-size: 14px;
  10. }
  11. table{
  12. border-collapse: collapse;
  13. width: 70%;
  14. margin: auto;
  15. color: #666;
  16. font-weight: lighter;
  17. text-align: center;
  18. }
  19. table thead th, table td{
  20. border-bottom: 1px solid #bbb;
  21. padding: 10px;
  22. }
  23. table caption{
  24. font-size: 1.6rem;
  25. font-style:inherit;
  26. font-stretch: extra-expanded;
  27. font-weight: bolder;
  28. margin-bottom: 15px;
  29. color: darkblue;
  30. }
  31. table th{
  32. font-weight: lighter;
  33. color: yellow;
  34. }
  35. table thead tr:first-of-type{
  36. background-color: darkslategray;
  37. }
  38. table tbody tr:nth-of-type(even){
  39. background-color:lightgoldenrodyellow;
  40. }
  41. table tbody tr:hover{
  42. background-color:lawngreen;
  43. cursor: pointer;
  44. }
  45. table tfoot td{
  46. color: gold;
  47. background-color: gray;
  48. font-size: 1.05rem;
  49. font-weight: bolder;
  50. }
  51. body div:last-of-type{
  52. width: 70%;
  53. margin: 10px auto;
  54. }
  55. body div:first-of-type button{
  56. float:right;
  57. widows: 120px;
  58. height: 32px;
  59. background-color: slateblue;
  60. color:gold;
  61. border:none;
  62. cursor:pointer;
  63. }
  64. body div:first-of-type button:hover{
  65. background-color: gold;
  66. font-size: 1.3rem;
  67. color:black;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <table>
  73. <caption>魔法商店</caption>
  74. <thead>
  75. <tr>
  76. <th>编号</th>
  77. <th>名称</th>
  78. <th>限购</th>
  79. <th>魔豆</th>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. <tr>
  84. <td></td>
  85. <td>蓝扫把</td>
  86. <td>仙气五级及以上</td>
  87. <td>356</td>
  88. </tr>
  89. <tr>
  90. <td></td>
  91. <td>方金铲</td>
  92. <td>仙气三级及以上</td>
  93. <td>498</td>
  94. </tr>
  95. <tr>
  96. <td></td>
  97. <td>蛇尾绳</td>
  98. <td>仙气十二级及以上</td>
  99. <td>9996</td>
  100. </tr>
  101. <tr>
  102. <td></td>
  103. <td>水边草</td>
  104. <td>仙气四级及以上</td>
  105. <td>786</td>
  106. </tr>
  107. <tr>
  108. <td></td>
  109. <td>鞋底虫</td>
  110. <td>仙气七级及以上</td>
  111. <td>1262</td>
  112. </tr>
  113. </tbody>
  114. <tfoot>
  115. <tr>
  116. <td colspan="3">总括</td>
  117. <td>15116</td>
  118. </tr>
  119. </tfoot>
  120. </table>
  121. <div>
  122. <button>收入囊中</button>
  123. </div>
  124. </body>
  125. </html>

3、注册页面

自己的没有用到password和复选框,后面有机会可以练习。
```html
<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>魔法世界注册</title>
<style>
body{
color: #555;
}
h3{
text-align: center;
}
form{
width: 450px;
margin: 30px auto;
border-top: 1px solid #aaa;
}
form fieldset{
border: 1px solid steelblue;
background-color: turquoise;
box-shadow: 2px 2px 4px #aaa;
border-radius: 5px;
margin: 20px;
}
form fieldset legend{
background-color: blueviolet;
color: burlywood;
border-radius: 5px;
padding: 5px 15px;
}
form div{
margin: 5px;
}
form p{
text-align: center;
}
form .btn{
width: 75px;
height: 30px;
border: none;
background-color: darkgoldenrod;
color: darkslategrey;
}
form .btn:hover{
background-color: darkturquoise;
color: dimgrey;
cursor: pointer;
}
input:focus{
background-color: dodgerblue;
}
</style>
</head>

<body>
<h3>欢迎来到妖魔神仙世界</h3>
<form action="" method="post">
<fieldset>
<legend>登记造册</legend>
<div>
<label for="" name="" id="">王名
<input type="text" name="" placeholder="您的王名是啥" autofocus>
</label>
</div>

  1. <div>
  2. <label for="">王类
  3. <input type="radio" value="妖怪" name="type" id="type1"> <label for="type1">妖怪</label>
  4. <input type="radio" value="神仙" name="type" id="type2"> <label for="type2">神仙</label>
  5. </lable>
  6. </div>
  7. <div>
  8. <label for="">非凡龄
  9. <input type="int" placeholder="999">
  10. </label>
  11. </div>
  12. </fieldset>
  13. <fieldset>
  14. <legend>不过你还需要补充下面这些信息</legend>
  15. <div>
  16. <label for="">你的牛哭图
  17. <input type="file" accept="image/png, image/jpg, image/jpeg">
  18. </label>
  19. </div>
  20. <div>
  21. <label for="">你的作孽/战绩
  22. <textarea name="log" id="log" placeholder="作孽多少,战胜妖魔鬼怪多少">
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议