一个
<input>的宽度从其生成
size属性。默认值
size是驱动自动宽度的原因。
您可以
width:100%按照下面的示例所示尝试。
不填充宽度:
<form action='' method='post' style='width:200px;background:khaki'> <input style='width:auto' /></form>
填充宽度:
<form action='' method='post' style='width:200px;background:khaki'> <input style='width:100%' /></form>
尺寸更小,宽度更小:
<form action='' method='post' style='width:200px;background:khaki'> <input size='5' /></form>
更新
几分钟后,这是我能做的最好的事情。在FF,Chrome和Safari中关闭1像素,在IE中完美显示。(问题是#^&*
IE应用边框的方式与其他方式不同,因此不一致。)
<div style='padding:30px;width:200px;background:red'> <form action='' method='post' style='width:200px;background:blue;padding:3px'> <input size='' style='width:100%;margin:-3px;border:2px inset #eee' /> <br /><br /> <input size='' style='width:100%' /> </form></div>



