2011-05-19 23 views
3

value屬性有時會更改爲很長,超過50px。IE7中的按鈕換行

<input type="submit" Value="Really long" style="width:50px; white-space:normal" /> 

這在IE8 +和firefox中正常工作,因爲按鈕上的文本會換行到下一行。

問題是這已經在IE7中工作,文本沒有換行。

有誰知道如何使它在IE7中包裝?

+0

在IE7中,您必須在HTML源代碼中包含手動換行符。見下面的答案。 – Ryan 2011-05-20 18:23:24

+0

下面是解決方案,它適用於我:) http://stackoverflow.com/questions/5808137/word-wrapping-for-button-with-specified-width-in-ie7?answertab=active#tab -top – John 2014-05-08 18:58:27

回答

0

不確定你想達到什麼,但是,你可能想嘗試在輸入標籤中使用size屬性,AS和你的css。

<input size="50" type="submit" Value="Really long" style="width:50px; white-space:normal" />

+0

The'size' attr。將被'width' CSS屬性覆蓋。 – jackJoe 2011-05-19 21:45:48

+0

不過,這是值得一試,以防萬一(它不會傷害) – seesharper 2011-05-19 21:49:01

-1

插入<br />到價值,並確保doctype正確指定。

+0

您不能插入標籤,如
到屬性的值。 – 2011-07-12 12:46:29

2

一個雜牌的一點,但這會在IE7渲染大多是正確的:

<input type="submit" Value="Really 
long" style="width:50px; white-space:normal" /> 

基本上,你必須在你的HTML添加換行符。這種'技巧'是一種解決方法...如果你手動編寫你的HTML,它將是一個選項,但是如果你的代碼被生成(例如ASP.Net),它可能不起作用。

請參閱this jsFiddle在IE7中。

2

我很不幸仍然支持IE7並遇到此問題。如果您能夠將<input />更改爲<button>,則可以使用display:inline-block將按鈕嵌入<span>以解決溢出問題。

<button> 
    <span style="display:inline-block">Long button text goes here</span> 
</button>