【发布时间】:2012-09-11 14:13:44
【问题描述】:
【问题讨论】:
-
可以手动调整输入宽度吗?
-
你能更准确地描述你在寻找什么吗?
【问题讨论】:
解决方案 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 姓名 邮编和城市
解决方案 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>
【讨论】:
现在查看结果,链接如下-http://jsfiddle.net/HSkyq/4/
【讨论】: