带有空格nowrap的HTML表
嘿,我想知道你是否可以有一个HTML表,并确保某些列有带有空格nowrap的HTML表,html,css,Html,Css,嘿,我想知道你是否可以有一个HTML表,并确保某些列有空白:nowrap,而其他列有空白:normal 例如: <table> <thead> <tr> <th>No wrap</th> <th>Wrap</th> </tr> </thead> <tbody>
空白:nowrap
,而其他列有空白:normal
例如:
<table>
<thead>
<tr>
<th>No wrap</th>
<th>Wrap</th>
</tr>
</thead>
<tbody>
<tr>
<td>Small text</td>
<td>Wrap this longgggg text</td>
</tr>
</tbody>
</table>
无包装
包
小文本
将此长文本换行
默认情况下是normal
,因此您只需将某些列的值设置为nowrap
。一种方法是向它们添加一个类,如下所示:
<td class="my_nowrap">this won't wrap</td>
<style>
.my_nowrap {
white-space: nowrap;
}
</style>
这不会自动换行
.my_nowrap{
空白:nowrap;
}
另一种方法是使用和(不设置类)针对某些列,如下所示:
<style>
td:nth-child(2),
td:nth-child(3) {
.my_nowrap {
white-space: nowrap;
}
</style>
td:N个孩子(2),
运输署:第n名儿童(3){
.my_nowrap{
空白:nowrap;
}
上面将第2列和第3列设置为
nowrap
是的,这是可能的。请看下面的示例
表,th,td{
边框:1px纯黑;
边界塌陷:塌陷;
}
th,td{
填充物:5px;
文本对齐:左对齐;
}
包裹{
宽度:50px;
}
th.wrap,td.wrap{
背景:红色;
溢出:隐藏;
空白:nowrap;
文本溢出:省略号;
最大宽度:10px;
}
名称
电话
比尔盖茨
555 77 854
555 77 855
如果你能举个例子就好了。。