2012-10-12 50 views
0

我想將主div的靜態寬度設置爲300px。但是,當任何用戶從Word程序中複製和粘貼文本時,然後從div中更改表格寬度和溢出文本。但我的網站的寬度必須是最大300px。我怎麼解決這個問題?來自div的文本溢出

<html> 
<head> 
<style> 
#main td{ 
max-width:300px; 
} 

#main table{ 
max-width:300px; 
} 

</style> 
</head> 

<body> 
<div id="main"> 
<table width="700" border="1"> 
<tr> 
<td width="800"><p width="900">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</td> 
</tr> 

<tr> 
<td width="800"><p with="900">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></td> 
</tr> 
</table> 
</div> 
</body> 
</html> 

回答

0

變化

#main table{ 
max-width:300px; 
} 

#main *{ 
max-width:300px; 
} 

這樣一來,TD,IMG和其他人仍然會被調整大小。此外,您可以在#main div上使用overflow-x:hidden來隱藏太大而不適合的內容。

+0

但我不想隱藏溢出文本。 div的句子結尾會下到底線? –

+0

不使用溢出:隱藏然後。不知道你的第二句話 – Salketer

+0

是什麼意思, 1asdadad 2asdadad 3asdadasd 4asdasdasd 4個單詞。 2字以後第三個字將底線? –

0

我會建議在Word文本上做一些類型的衛生來移除不需要的內聯樣式。無論如何,你總是將文字傳到網上的文字。你可以使用像tinyIMCE或類似的東西。這樣你就不必擔心他們拷貝什麼,它總是會服從CSS。

+0

是的你對編輯是正確的,我已經使用了cke。但仍然存在問題 –