将带有空格的单词放在不同行的表格
我正在尝试用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试将空白的 CSS 属性添加到表格的
元素中。特别是
Try adding CSS attribute of white-space to the
<td>
elements of the table. In particular,<td style='white-space: no-wrap;'>
您可以使用
来实现此目的。这样浏览器就会将其视为一个单词。
You can use
for this. That way the browser sees it as one word.
你期望什么?
假设窗口变小,单元格也变小,无法完全容纳
联系我们
,那么您是否期望隐藏“额外”内容?单元格的大小永远不会小于固定的最小值?您需要使用
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
adheight
along withoverflow
(overflow).overflow:hidden
will hide the content that is more than thewidth
(provided aheight
is given)