-1

Please see this little HTML form

I'd like to have ZIP & city input fields on one line, but on the right have the city input field end with the name input field on one line.

How could I do that? Thanks.

4

2 回答 2

1

解决方案1:http: //jsfiddle.net/wMUAK/

CSS

label {
    float: left;
    width: 100px;
    padding: 2px;
}

.c1 {
    float: left;
    width: 200px;
}

.c2 {
    float: left;
    width: 40px;
    margin-right: 10px;
}

.c3 {
    float: left;
    width: 150px;
}

.c1 input[type=text],
.c2 input[type=text],
.c3 input[type=text] {
    width: 100%;
}

.clear {
    clear: both;
}

HTML 名称 ZIP 和城市

解决方案2:http: //jsfiddle.net/HSkyq/5/

CSS

.table {
    display: table;
}

.table .row {
    display: table-row;
}

.table .cell {
    display: table-cell;
}

.group {
    display: table;
    width: 100%;
}

.group .gcell {
    display: table-cell;
}

.table input {
    width: 100%;
}​

HTML

<div class="table" style="width: 300px;">
  <div class="row">
    <div class="cell" style="width:40%;">
      <label for="name">Name</label>
    </div>
    <div class="cell">
      <input type="text" id="name" name="name" />
    </div>
  </div>
  <div class="row">
    <div class="cell">
      <label for="city">ZIP and city</label>
    </div>
    <div class="cell">
      <div class="group">
        <div class="gcell" style="width: 40%;">
          <input type="text" name="zip" style="width: 90%;" />
        </div>
        <div class="gcell">
          <input type="text" name="city" id="city" />
        </div>
      </div>
    </div>
  </div>
</div>​
于 2012-09-11T14:41:50.550 回答
0

现在查看结果,链接如下——http: //jsfiddle.net/HSkyq/4/

于 2012-09-11T14:38:55.530 回答