默認情況下,輸入元素的大小=「20」(如果未內聯定義或CSS樣式規則歸因於該元素)。默認輸入元素大小
你如何使默認值的實際大小?對於其他元素:
<div style="display: inline; width: auto;">
The box will only fit the width of it's content
</div>
寬度:自動是你所需要的。由於該值可能會更長,因此我無法放置定義的寬度。例如:
<input id="short" type="text" value="1000" />
<input id="long" type="text" value=" Areally long name is in this input field." />
我想#short成爲1000(基本上大小=「4」 +填充),但#long大小爲只要需要。這些投入正在以編程方式進行,所以我不能簡單地在我想要的短期課程上加上一個短期課程,而在我想要的很長的課程上加上一個長期課程。我真的只是喜歡它,如果我可以把:
input { width: auto; }
無論如何要做到這一點?
可能重複[寬度:自動字段](http://stackoverflow.com/questions/4622086/widthauto-for-input-fields) – j08691 2012-07-31 20:37:57
我看到這一點和其他一些,但他們都試圖要做的是有一個輸入填寫父項。我希望根據內容的多個輸入大小。 – 2012-07-31 20:44:30
但它是一個確切的副本http://stackoverflow.com/questions/8100770/auto-scaling-inputtype-text-to-width-of-value – 2012-07-31 20:47:41