This is possible with CSS in user agents with CSS-2.x-supporting layout engines:
…
<style type="text/css">
.full-width {
width: 100%;
}
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
}
</style>
</head>
<body>
<ul class="table">
<li class="row">
<span class="cell full-width">
<input type="text" id="textField" class="full-width" />
</span>
<span class="cell">
<input type="button" value="foobar" />
</span>
</li>
</ul>
</body>
Tested positive in the following browsers:
- Chromium 16.0.912.75 (Developer Build 116452 Linux), Apple WebCore 535.7
- Chromium 16.0.912.63 (Developer Build 113337 Linux), Apple WebCore 535.1
Please note that paddings and margins on input
elements will interfere because of the fixed width.
But: I can see no good reason why you should not use a table
element here (tables and CSS do mix). Semantically it would make sense (the table would be serializable), and compatibility will be very likely better than with the CSS display
property values above:
<body>
<ul>
<li>
<table class="full-width"
summary="Input text field with “foobar” button">
<tr>
<td class="full-width">
<input type="text" id="textField" class="full-width" />
</td>
<td>
<input type="button" value="foobar" />
</td>
</tr>
</table>
</li>
</ul>
</body>
It is also possible that you should have used only a table
element here in the first place.