如何防止在表的列中自动换行(不是单个单元格)?


当前回答

要将它应用到整个表,你可以将它放在table标签中:

<表风格= "空白:nowrap;}" >

其他回答

<table class="blueTable">
  <tr>
     <td>My name is good</td>
   </tr>
</table> 
<style>   
    table.blueTable td,
    table.blueTable th {
        white-space: nowrap;
        /* non-question related further styling */
        border: 1px solid #AAAAAA;
        padding: 3px 2px;
        text-align: left;
    }
</style>

这是一个使用值为nowrap的空格属性的例子,bluetable是表的类,表下面是CSS样式。

<td style="white-space: nowrap">

我认为nowrap属性已弃用。以上是首选的方式。

使用nowrap样式:

<td style="white-space:nowrap;">...</td>

CSS !

只需添加

style="white-space:nowrap;"

例子:

<table class="blueTable" style="white-space:nowrap;">
   <tr>
      <td>My name is good</td>
    </tr>
 </table>

在文本中使用非换行空格,而不是常规空格。在Ubuntu上,我使用(Compose Key)-space-space。