将带有空格的单词放在不同行的表格

发布于 2024-09-26 00:31:57 字数 313 浏览 0 评论 0原文

我正在尝试用 HTML 制作一个表格。当我将窗口大小缩小到较窄时,即使窗口很窄,窗口也会尝试挤压所有内容以适合窗口内,它会将单元格的内容放在不同的行上。我不希望这种事发生。例如:

home    about    contact us

当你缩小浏览器窗口时:

home    about    contact
                 us

这真的很烦人。我尝试将   而不是空格所在的空格,但没有帮助。有谁知道解决方案吗?

I am trying to make a table in HTML. When I resize the window down to be narrow and the window tries to squash everything to fit inside the window even though it's narrow, it puts the contents of a cell on different lines. I don't want this to happen. E.g.:

home    about    contact us

when you narrow down the browser window:

home    about    contact
                 us

This is really annoying. I have tried putting   instead of a space where the space is, but it didn't help. Does anyone know the solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冷弦 2024-10-03 00:31:57

尝试将空白的 CSS 属性添加到表格的 元素中。特别是

Try adding CSS attribute of white-space to the <td> elements of the table. In particular, <td style='white-space: no-wrap;'>

段念尘 2024-10-03 00:31:57

您可以使用   来实现此目的。这样浏览器就会将其视为一个单词。

You can use   for this. That way the browser sees it as one word.

待天淡蓝洁白时 2024-10-03 00:31:57
td { white-space:nowrap; }
td { white-space:nowrap; }
惜醉颜 2024-10-03 00:31:57

你期望什么?

假设窗口变小,单元格也变小,无法完全容纳联系我们,那么您是否期望隐藏“额外”内容?单元格的大小永远不会小于固定的最小值?

您需要使用 width 广告 height 以及 overflow (溢出)。 overflow:hidden 将隐藏超过宽度的内容(假设给出了高度

What do you expect?

Say the window becomes smaller so that the cell also becomes smaller than to fit contact us completely, then do you expect The "extra" content to be hidden? The size of the cell never become smaller than a fixed-minimum?

You need to use width ad height along with overflow (overflow). overflow:hidden will hide the content that is more than the width (provided a height is given)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文