0

I'm trying to display 2 form boxes on one line and another below them. Anything I try with divs cannot get these 2 fields to separate. I've even tried to insert   between them with no luck.

Here's my html:

<div class="form-line">
  <input class="input-text" id="name-box" type="text" name="name" value="Name">
  <input class="input-text" id="mail-box" type="text" name="mail" value="Email">
</div>

CSS:

.input-text {
  padding-left: 3px;
  font-family: sans-serif;
}

.input {
  display: inline;
}

.form-line {
  padding-top: 5px;
  clear:both;
}

#name-box {
  float: left;
}

#mail-box {
  float: left;
}

Can you please give me an idea of how to put 10px between these boxes? Thanks.

4

3 回答 3

3

您需要将您input的 s 设置为display:inline-block(在 IE 8 及更低版本上无法使用,除非您稍微修改一下):

input {
    display: inline-block;
    padding:0 5px;


    /** Just for IE <= 8 */
    *display:inline;
    *zoom:1;
}

这是一个有效的 jsfiddle

于 2013-08-11T13:15:30.547 回答
0

给邮箱 margin-left ,所以你的邮箱 css 将是

#mail-box {
  float: left;
    margin-left:10px;
}
于 2013-08-11T13:17:15.363 回答
0

要将第二个安排在第一个的右侧:

.form-line>input{display:inline-block}
.form-line>input+input{margin-left:10px}
于 2013-08-11T13:15:28.150 回答