Sco*_*ttS 12
是的,在一些地方HTML和CSS是使用了一些魔法之间float
和overflow: hidden
,你可以看到它在这个拨弄工作.
HTML
<div class="container">
<div>Some Text</div>
<form>
<button>MyButton</button>
<div class="stretcher"><input type="text" /></div>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.stretcher {
overflow: hidden;
}
button {
float: right;
}
input {
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
Wil*_*tal 12
我喜欢ScottS的答案,但只是有一个替代方案:你可以在CSS中使用类似表格的行为:
CSS
.formline{
display: table;
}
.txt{
display: table-cell;
width: 100%;
}
input[type=text]{
-moz-box-sizing: border-box; box-sizing: border-box;
width: 100%;
}?
Run Code Online (Sandbox Code Playgroud)
HTML
<div class=formline>
<div class=txt>
<input type=text>
</div>
<input type=submit value=submit>
</div>
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/willemvb/VaFSP/