0


HTML表格、表单、标签、CSS、选择器

一、HTML表格

table:表格

tr:行

td:单元格;rowspan:纵向合并相邻单元格;clospan:横向合并相邻单元格

th:单元格加粗居中

border:加上边框

cellspacing:边框与边框之间距离

cellpadding:控制边框大小

caption:表格标题

align:使表格居中

  1. <!--th 加粗居中>
  2. <th>序号</th>
  3. <th>姓名</th>
  4. <th>性别</th>
  5. <th>年</th>
  6. <th>班级</th>
  1. <td>1</td>
  2. <td>小英</td>
  3. <td></td>
  4. <td>18</td>
  5. <td>1班</td>
  1. <td>2</td>
  2. <td>a</td>
  3. <td></td>
  4. <td>19</td>
  5. <td>1班</td>
  1. <td>3</td>
  2. <td>b</td>
  3. <td></td>
  4. <td>20</td>
  5. <td>2班</td>
  1. <td>合计</td>
  2. <td>3人</td>
  3. <td></td>
  4. <td></td>
  5. <td></td>
学生信息表

实现效果:

将第5列两行的1班合并,将第5行的二三四五列的人数合并

  1. <!--th 加粗居中>
  2. <th>序号</th>
  3. <th>姓名</th>
  4. <th>性别</th>
  5. <th>年</th>
  6. <th>班级</th>
  1. <td>1</td>
  2. <td>小英</td>
  3. <td></td>
  4. <td>18</td>
  5. **<td rowspan="2">1班</td>**
  1. <td>2</td>
  2. <td>a</td>
  3. <td></td>
  4. <td>19</td>
  5. ** <!--<td>1班</td> -->(注释掉)**
  1. <td>3</td>
  2. <td>b</td>
  3. <td></td>
  4. <td>20</td>
  5. <td>2班</td>
  1. <td>合计</td>
  2. ** <td clospan="4">3人</td>**
  3. ** <!-- <td></td>**

**

**

**

--> (注释掉)**

学生信息表

实现效果:

二、表单

1.常见:登录注册

form:表单

action:提交表单的输入值到目标地址

input: 输入标签,用于获取用户在网页中的键盘、鼠标输入

·placeholder:输入框中的提示文字

<input placeholder="请输入"></input>

·name:最终提交表单时,该项输入框的数据描述(例如传到网址上,就是?后面的参数值)

<form>
  1. <input name="account"></input>
  2. <input name="password"></input>
</form>

表示此表单中,分别有输入账号和密码 的 输入框

·value:输入框最终的【输入值/选中值/按钮文字】

<input value="123123">

label:点击到<label>时,会自动聚焦到其绑定的<input>标签

·for绑定<input>标签 id值

<label for="username">用户名</label>

<input id="username"></input>

disabled:禁止该<input>【输入/选择】

type:通过修改type的值, 可以更改输入框的功能

·text:普通的文本输入框

<input type="text"> </input>

·password:密码输入框

<input type="password"></input>

·radio:单选框,

搭配checked: 默认选择;搭配disabled:禁止使用

<input type="radio" checked></input>

<input type="radio" disabled></input>

·checkbox:多选框

<input type="checkbox" checked></input>

<input type="checkbox" disabled></input>

·file:选择文件

<input type="file"> </input>

·submit:提交按钮

<input type="submit"></input>

·reset:重置按钮

<input type="reset"></input>

·button:普通按钮,需要写value值,按钮才有文字

<input type="button" value=" "></input>

例:

  1. <form action="https://www.baidu.com/">
  2. <p>
  3. <span>昵称:</span>
  4. <input type="text" name="nickname" value="one" id="nick">
  5. <label for="nick"></label>
  6. </p>
  7. <p>
  8. <span>年龄:</span>
  9. <input type="text" name="age" id="old">
  10. <label for="old"></label>
  11. </p>
  12. <p>
  13. <span>性别:</span>
  14. <input type="radio" name="sex" value="1" id="man">
  15. <label for="man"></label>
  16. <input type="radio" name="sex" value="0" id="woman">
  17. <label for="woman"></label>
  18. </p>
  19. <p>
  20. <span>城市:</span>
  21. <input type="radio" name="city" value="three" id="fu">
  22. <label for="fu">福州</label>
  23. <input type="radio" name="city" value="four" id="zz">
  24. <label for="zz">漳州</label>
  25. </p>
  26. <p>
  27. <input type="submit" name="submit" value="提交">
  28. <input type="reset" name="reset" value="取消">
  29. </p>
  30. </form>

实现效果:

2.多行文本<textarea> </textarea>

cols:规定初始显示的【列数】(以字为单位)

rows:规定初始显示的【行数】(以字为单位)

<textarea name="text" id=" " cols="10" rows="2"></textarea>

3.下拉选择框

select:下拉选择框容器

option:选项

<select id="taste">
  1. <option value="1">微辣</option>
  2. <option value="2"></option>
</select>

<label for="taste"></label>

例:

  1. <p>
  2. <span>城市:</span>
  3. <select id="city">
  4. <option value="01">福州</option>
  5. <option value="02">漳州</option>
  6. <option value="03">厦门</option>
  7. <option value="04">泉州</option>
  8. <obtion value="05">宁德</obtion>
  9. <option value="06">莆田</option>
  10. </select>
  11. <label for="city">
  12. </label>
  13. </p>
  14. <p>
  15. <textarea name="text" rows="20" cols="30">
  16. </textarea>
  17. </p>

实现效果:

三、布局标签

div标签:块级元素标签

特点:常用于而划分一块区域,一定占整行宽度,并且换行,搭配CSS使用。

span标签:行内元素标签

特点:没有任何默认样式,宽高随文字撑开,不会换行。

四、CSS

1.定义:

层叠样式表:显示设备在视觉上是二维平面的,实际上是多层图层叠加显示的效果,从上往下叠加的效果,!important最优先效果。

2.书写格式:

选择器{样式属性1:值1;属性2:值2}

3.书写位置:

①内联样式:直接写在标签的style属性中,无法重复使用代码。

内联样式

内联样式

<input type="text" style="width:50px; background-color:green"></input>

②内部样式:在html文件的<head></head>标签域中,添加<style></style>标签,将

代码书写其中,可以通过选择器重复使用代码。

内联优先级>内部

③外部样式:写在新的一个文件,通过link连接两个文件

内部优先级>外部

**!important: **

五、选择器

id选择器:id="happy"

<style> #happy{ width:100px; } </style>

class选择器:class="sad"

<style> .sad{ width:50px; } </style>

** 子元素选择器:**

相邻元素选择器:

标签: html css 前端

本文转载自: https://blog.csdn.net/2301_80034711/article/details/141107555
版权归原作者 live梨 所有, 如有侵权,请联系我们删除。

“HTML表格、表单、标签、CSS、选择器”的评论:

还没有评论