【问题标题】:nowrap on td in table but not if colspannowrap on td in table 但不是 colspan
【发布时间】:2019-04-04 06:43:58
【问题描述】:

是否可以根据单元格 (td) 是否具有 colspan 属性来控制表格单元格的 nowrap?

当前的css

.k2table {table-layout: fixed; width:100%;border-collapse: collapse}
.k2table tr {height:18px} 
.k2table td {text-align: left;padding:1px;white-space: nowrap;} 
.k2table td+td {text-align: right;width:70px;} 
.k2table td+td+td {text-align: right;width:70px;} 

如果我有如下表,我不想在 td 上使用 colspan 进行 nowrap。

<table class="k2table">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
</table>

【问题讨论】:

    标签: html-table nowrap


    【解决方案1】:

    您可以使用 [attr] 选择器来做到这一点

    .k2table td[colspan] { white-space: normal }
    

    如果您需要更具体,您可以使用 THAT colspan 将您的样式应用到单元格

    .k2table td[colspan="3"] { white-space: normal }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-26
      • 2018-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 2017-01-30
      相关资源
      最近更新 更多