表格和表单标签

数据表格的创建

数据表格的创建
请添加图片描述
快速创建
(1)

table>tr>td

请添加图片描述
(2)

table>tr>td*2

请添加图片描述
(3)

  table>(tr>td*2)*2

等价于

table>tr*2>td*2

请添加图片描述

table表格的属性

table表格的属性

1.宽度width
2.高度height
3.边框border
4.边框颜色bordercolor
5.背景颜色bgcolor
6.水平对齐 align="left或right或center"7. cellspacing=" 单元格与单元格之间的间距“
8. cellpadding=" 单元格与内容之间的空隙"
width px或者百分比(相对于父元素的)
height px或者百分比(相对于父元素的)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table border="1" width="50%" height="500px"
    align="center"
    bordercolor="red"
    bgcolor="yellow"
    cellspacing="0"
    cellpadding="0">
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </table>
</body>
</html>

请添加图片描述

行tr属性

行tr属性

高度.height
背景颜色bgcolor
文字水平对齐align="left或 right或center
文字垂直对齐valign="top或 middle或bottom'
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table border="1" width="300px" height="300px" align="center"
    bgcolor="yellow">
        <tr bgcolor="orange" height="100px" align="center" valign="bottom">
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </table>
</body>
</html>

请添加图片描述

单元格td属性

单元格td属性

宽度width
高度height
背景颜色bgcolor
文字水平对齐 align="left或right或 center'
文字垂直对齐 valign="top或 middle或bottom";

td: 如果一个单元格的设置宽度,影响的是这一整列的宽度
td:如果一个单元格的设置高度,影响的是这一整 行的高度

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table border="1" width="300px" height="300px" align="center"
    bgcolor="yellow">
        <tr>
            <td width="200px">1</td>
            <td height="200px">2</td>
        </tr>
        <tr>
            <td bgcolor="red">3</td>
            <td align="right" valign="top">4</td>
        </tr>
    </table>
</body>
</html>

请添加图片描述

表格合并列

表格合并列
Colspan=“所要合并的单元格的列数”必须给td
请添加图片描述
Rowspan=“所要合并的单元格的行数"必须给td
请添加图片描述

表格练习

表格练习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
        <tr height="50px" align="center">
            <td width="100px">会员姓名</td>
            <td width="150px"></td>
            <td width="100px">出生日期</td>
            <td width="100px"></td>
        </tr>
        <tr height="50" align="center">
            <td>身份证号</td>
            <td colspan="3"></td>
            <!-- <td></td>
            <td></td> -->
        </tr>
        <tr height="50" align="center">
            <td>通讯地址</td>
            <td colspan="3"></td>
            <!-- <td></td>
            <td></td> -->
        </tr>
        <tr height="50" align="center">
            <td>联系电话</td>
            <td colspan="3"></td>
            <!-- <td></td>
            <td></td> -->
        </tr>
        <tr height="50" align="center">
            <td>会员卡号</td>
            <td colspan="3"></td>
            <!-- <td></td>
            <td></td> -->
        </tr>
    </table>
</body>
</html>

请添加图片描述

表单标签

表单标签
表单的作用:收集用户信息。
请添加图片描述
请添加图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="http://www.baidu.com" method="post">
        输入框:<input type="text" placeholder="请输入用户名" name="username">
        <br>
        密码框:<input type="password" placeholder="请输入密码" name="mima">
        <br>
        <button type="reset">重新输</button>
        <h2>复选框:</h2>
        <input type="checkbox">苹果
        <input type="checkbox">香蕉
        <input type="checkbox">橘子
        <h2>复选框:</h2>
        <input type="checkbox" checked>苹果<!-- 默认选中 -->
        <input type="checkbox">香蕉
        <input type="checkbox">橘子
        <h2>复选框:</h2>
        <input type="checkbox">苹果
        <input type="checkbox" disabled>香蕉<!-- 选中不了 -->
        <input type="checkbox">橘子
        <h2>单选框:</h2>
        <input type="radio" name="gender"><input type="radio" name="gender"><h2>上传文件</h2>
        <input type="file">
        <h2>提交按钮和重置按钮</h2>
        <input type="submit" value="提交">
        <input type="reset">
        <h2>多行文本框</h2>
        <textarea cols="30" rows="10"></textarea>
        <h2>下拉菜单</h2>
       <!--  第一种 -->
        <select>
            <option selected disabled>请选择</option>
            <option>南京</option>
            <option>连云港</option>
            <option>徐州</option>
        </select>
        <br>
        <!-- 第二种 -->
        <select size="2"><!-- 调整选项个数 -->
            <option>南京</option>
            <option>连云港</option>
            <option>徐州</option>
        </select>
        <br>
        <select multiple><!-- 多选 -->
            <option>南京</option>
            <option>连云港</option>
            <option>徐州</option>
        </select>
        <br>
        <input type="file"multiple><!-- 列子 -->
        <br>
        <input type="radio" name="gender" id="man"><label for="man"></label>
        <input type="radio" name="gender" id="woman"><label for="women"></label>
    </form>
</body>
</html>

请添加图片描述
请添加图片描述

表格与表单组合

表格与表单组合

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=<<device-width>>, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="">
        <table border="1" cellpadding="30"> 
            <tbody>
                <tr align="center">
                    <td rowspan="4"> 总体信息</td>
                    <td colspan="2">用户注册</td>
                </tr>
                <tr align="right">
                    <td>用户名:</td>
                    <td><input type="text" placeholder="请输入用户名"</td>
                </tr>
                <tr align="right">
                    <td>密码:</td>
                    <td><input type="password" placeholder="请输入密码"</td>
                </tr>
                <tr align="center">
                    <td colspan="2"> 
                    <input type="submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="reset">
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>

请添加图片描述

单选框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <div>你的性别</div>
        <div>
            <input type="radio" name="aaa" id="man">
            <label for="man">男</label>
        </div>
        <div>
            <input type="radio" name="aaa" id="woman">
            <label for="woman">女</label>
        </div>
    </div>

    <div>
        <div>满意度调查</div>
        <div>
            <input type="radio" name="ccc" checked>非常满意
        </div>
        <div>
            <input type="radio" name="ccc">满意
        </div>
    </div>
</body>
</html>

请添加图片描述

复选框

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <div>你的兴趣爱好</div>
        <div>
            <input type="checkbox" name="aaa">抽烟
            <input type="checkbox" name="aaa">喝酒
            <input type="checkbox" name="aaa">烫头
        </div>
    </div>
    <div>
        <div>你擅长的技术</div>
        <div>
            <input type="checkbox" name="bbb" id="html">
            <label for="html">html</label>
            <input type="checkbox" name="bbb" id="css">
            <label for="css">css</label>
            <input type="checkbox" name="bbb" id="js">
            <label for="js">js</label>
        </div>
    </div>
    <div>
        <div>你的兴趣爱好</div>
        <div>
            <input type="checkbox" name="aaa">抽烟
            <input type="checkbox" name="aaa" checked="checked">喝酒
            <input type="checkbox" name="aaa" checked>烫头
        </div>
    </div>
</body>
</html>

请添加图片描述

上传文件和隐藏字段

请添加图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <div>请截图说明</div>
        <div>
            <!-- 上传文件 -->
            <input type="file" name="" id="">
        </div>
    </div>

    <div>
        <div>隐藏按钮</div>
        <div>
            <input type="hidden" name="" id="" value="带给后端的个人信息">
        </div>
    </div>

    <div>
        <div>禁用,只读</div>
        <div>
            <button disabled="disabled">注册</button>
            <br>
            <input type="radio" disabled>不满意
            <br>
            <input type="text" disabled value="111111">
            <br>
            <input type="text" readonly value="111111">
        </div>
    </div>
</body>
</html>

请添加图片描述

下拉菜单

请添加图片描述
请添加图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>下拉菜单</h1>
    <div>你的收获地址</div>
    <select name="" id="">
        <option value="">辽宁</option>
        <option value="">山东</option>
        <option value="">山西</option>
        <option value="">河北</option>
    </select>
    <div>
        <select size="3" multiple>
            <option>桌子</option>
            <option>椅子</option>
            <option>凳子</option>
            <option>电脑</option>
        </select>
    </div>

    <div>
        <select size="3" multiple>
            <option value="" disabled>桌子</option>
            <option value="">椅子</option>
            <option value="">凳子</option>
            <option value="">电脑</option>
        </select>
    </div>
</body>
</html>

请添加图片描述

文本域

请添加图片描述

resize重新设置大小,vertical垂直 horizontal水平both,none

请添加图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        textarea{
            width: 300px;
            height: 300px;
            resize: both;
            /* resize重新设置大小,vertical垂直 horizontal水平both,none */
        }
    </style>
</head>
<body>
    <div>
        <textarea name="" id="" cols="30" rows="10" placeholder="请输入"></textarea>
    </div>
</body>
</html>

请添加图片描述

字段集

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        fieldset{
            border: 1px solid blue;
        }
        legend{
            border: 1px solid red;
            text-align: center;
            padding: 10px;
        }
    </style>
</head>
<body>
    <h1>字段集</h1>
    <fieldset>
        <legend>性别</legend>
        <input type="radio" name="aa">男
        <br>
        <input type="radio" name="aa">女
    </fieldset>
</body>
</html>

请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值