我有一个 HTML 表单元素:
<form action="doit" id="doit" method="post">
Name <br/>
<input id="name" name="name" type="text" /> <br/>
Phone number <br/>
<input id="phone" name="phone" type="text" /> <br/>
Year <br/>
<input id="year" name="year" type="text" /> <br/>
</form>
我希望字段之间有更多的空间,例如,行之间
<input id="name" name="name" type="text" /> <br/>
和
Phone number <br/>
,
还有在
之间 <input id="phone" name="phone" type="text" /> <br/>
和 Year <br/>
.
我该怎么做?
最佳答案
我会用标签包裹你的行
<form action="doit" id="doit" method="post">
<label>
Name
<input id="name" name="name" type="text" />
</label>
<label>
Phone number
<input id="phone" name="phone" type="text" />
</label>
<label>
Year
<input id="year" name="year" type="text" />
</label>
</form>
并使用
label, input {
display: block;
}
label {
margin-bottom: 20px;
}
不要使用 br
作为间距!
演示:http://jsfiddle.net/D8W2Q/
关于html - 表单字段之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16379187/