0

我想要主 div 的静态宽度为 300px。但是当任何用户从 Word 程序中复制和粘贴文本时,就会更改表格宽度并从 div 溢出文本。但我网站的宽度必须最大为 300 像素。我怎么解决这个问题?

<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> 
4

2 回答 2

0

Change

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

To

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

That way, the TD, img and others will still be sized. Also, you could use overflow-x:hidden on your #main div to hide the content that is too big to fit.

于 2012-10-12T10:57:40.747 回答
0

我建议对 Word 文本进行某种类型的清理,以删除不需要的内联样式。无论如何,您应该始终清理从单词到网络的文本。你可以使用 tinyIMCE 或类似的东西。这样您就不必担心他们复制的内容,它将始终遵守 CSS。

于 2012-10-12T11:40:40.383 回答