There are already many questions raised about CSS & remaining width. After reading them I still have a problem I cannot fix. When trying to let an input element use up the remaining width it is always 4px wider than its containing div.
<!DOCTYPE html>
<html>
<body>
<div>
<div style='float:left; margin-right:10px;'>Hello:</div>
<div style='overflow:hidden'><input style='width:100%'/></div>
</div>
</body>
</html>
The input element is always 4 pixels too wide to show its right border. If I set the margin-left of the input to -4px it becomes visible but then the left border is not shown.
Tested this with Chrome.
You could add
box-sizing: border-box;to yourinputto avoid the overflow. What it does basically is that the borders and padding will be taken into consideration when settingwidth: 100%. Note that you’d have to include several vendor-prefixed for different browsers:Little demo: little link.