表单字段之间的间距

Mik*_* H. 2 html css forms

我有一个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>
Run Code Online (Sandbox Code Playgroud)

我希望在字段之间有更多的空间,例如,在行之间

<input id="name" name="name" type="text" /> <br/>而且 Phone number <br/>,

以及之间

<input id="phone" name="phone" type="text" /> <br/>Year <br/>.

我该怎么做?

Tur*_*nip 12

在您的CSS文件中:

input { margin-bottom: 10px; }
Run Code Online (Sandbox Code Playgroud)


Ste*_*ins 12

我会把你的行包装在标签中

<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>
Run Code Online (Sandbox Code Playgroud)

并使用

label, input {
    display: block;
}

label {
    margin-bottom: 20px;
}
Run Code Online (Sandbox Code Playgroud)

不要使用brs作为间距!

演示:http://jsfiddle.net/D8W2Q/