防止文本重叠表td宽度 [英] Prevent text from overlap table td width

查看:154
本文介绍了防止文本重叠表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.

这篇关于防止文本重叠表td宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆