防止文本重叠表td宽度
如果
条目过长,如何将表格< td>
限制为在整个屏幕上展开?
How can I restrict the table <td>
entry to expanding over the entire screen when
the entry is too long?
好吧,有 max-width
, max-height
和
overflow
。
所以
td.whatever
{
max-width: 150px;
max-height: 150px;
overflow: hidden;
}
会将最大宽度和高度限制为150像素,
would restrict the maximum width and height to 150px, and it can be anything from less than 150 up to 150, and anything that doesn't fit inside that will be clipped off and hidden from view.
溢出的默认值(溢出) :visible;
)是简单地允许任何不适合在其指定的容器内的东西只是溢出它的外面。如果你只想横向限制而不想隐藏任何东西, word-wrap
可能会有帮助:
Overflow's default (overflow: visible;
) is to simply allow anything that won't fit inside its specified container to just spill over outside of it. If you only want to limit it horizontally and don't want to hide anything, word-wrap
may help:
td.whatever
{
max-width: 150px;
word-wrap: break-word;
}
word-wrap
将会在需要时断言,即使它不在一个单词的结尾。您也可以使用 height
和 width
指定固定大小(如果您不希望表格展开)收缩。
word-wrap
will break words whenever it needs to, even if it's not at the end of a word. You can also just use height
and width
to specify a fixed size if you don't want the table to expand or shrink at all.