2012-06-22 47 views
1

我只想問我的html代碼在這裏,我有點問題,當涉及到我的div大小。當我把div的寬度設置爲70px時,內容仍然流過div,我想要的是,當div的高度超過div的寬度時,div的高度會自動調整。我的div的寬度是固定的,而內容仍然溢出

有幫助嗎? 繼承人我的代碼。在此先感謝

<div class = "center"> the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the 
lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps 
over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown 
fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the 
quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy dog.the quick brown fox jumps over the lazy 
dog.the quick brown fox jumps over the lazy dog. </div> 

<style> .center{width:70px;} </style> 
+0

在jsfiddle.net上做一個代碼示例 – SVS

+0

應該正常工作。您是否嘗試禁用/刷新瀏覽器緩存? – speakr

+0

http://jsfiddle.net/BQnae/這裏完美的工作 – treng

回答

2

試試這個CSS

.center 
{ 
    width:70px; 
    word-wrap: break-word; 
} 

強制瀏覽器打破,否則ecxeed容器的話。

+0

哦男人。非常感謝,我的問題解決了。這是我非常大的問題,非常感謝。 –

+0

你應該標記這回答然後 – casraf

0

添加以下的屬性到你的CSS類

overflow: auto; 
+0

更好的是,'隱藏',Firefox通常添加滾動條,當它不應該在這些情況下。 – casraf

1

您所描述的期望的行爲是默認行爲(proof) - 如果它不工作的方式,不是也有一些風格,干擾這個beahviour,嘗試消除它們。

此外,請注意<style>標記需要放在頭部,它不允許在身體中(嗯,準確地說 - 它是HTML5的屬性scoped但atm這是非常非常不好支持瀏覽器)

相關問題