在html中存在多行文字与多个<input type="text"|"checkbox"|"button"/>(或者其他类型)标签时,
由于文字的个数不能保持一致,从而导致后面的文字区的距离参差不齐
<html>
<head>
<title>调查问卷</title>
</head>
<body>
<p>用户信息表</p>
<form style = "border:1px soild red;">
姓名:<input type = "text" /><br>
年龄:<input type = "password" /><br>
性别:男<input type = "radio" >
女<input type = "radio" ><br>
喜欢的电影:<input type = "password" /><br>
个人特长:<input type = "password"/><br>
爱好:<input type = "checkbox" />滑雪
<input type = "checkbox" />爬山
<input type = "checkbox" />游泳
<input type = "checkbox" />上网
<input type = "checkbox" /> 踢球
</form>
</body>
</html>
代码效果:
这是由于字数差异导致文字区距离不一致。
解决办法:
<table border="1">
<tr>
<td></td>
</tr>
</table>
<html>
<head>
<title>调查问卷</title>
</head>
<body>
<table border="1">
<p>用户信息表</p>
<form style = "border:1px soild red;">
<tr><td>姓名:</td><td><input type = "text" /></td></tr>
<tr><td>年龄:</td><td><input type = "text" /></td></tr>
<tr><td>性别:</td><td>
男<input type = "radio" >
女<input type = "radio" ></td></tr>
<tr><td>喜欢的电影:</td><td> <input type = "text"/></td></tr>
<tr><td> 个人特长:</td><td><input type = "text" /></td></tr>
<tr><td>爱好:</td><td>
<input type = "checkbox" />滑雪
<input type = "checkbox" />爬山
<input type = "checkbox" />游泳
<input type = "checkbox" />上网
<input type = "checkbox" /> 踢球 </td></tr>
</form>
</tr>
</table>
</body>
</html>
效果
这是右边的文字区以及放在了单独的表格里,左面文字的长度不会影响到文字区的位置
如果想去掉文字中的边框,把代码中的
<table border="1">
border="1" 直接删除即可
最终效果: