一个人可以在另一个人里面吗? [英] Can a tbody be inside another one?

查看:85
本文介绍了一个人可以在另一个人里面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在这样的外部躯干中包含内部躯干:

Is it possible to have an inner tbody inside an outer tbody like this:

这是一个示例CSS:

  <style type="text/css">
    .class1 {background-color:#ff0000;}
    .class2 {background-color:#00ff00;}
  </style>

这是示例HTML

<table>
  <tbody id="outer" class="class1">
    <tr>
      <td>...</td>
      <td>...</td>
    </tr>
    <tbody id="inner" class="class2">
      <tr>
        <td>...</td>
        <td>...</td>
      </tr>
    </tbody> <!-- inner -->
    <tr>
      <td>...</td>
      <td>...</td>
    </tr>
  </tbody> <!-- outer -->
</table>

我的目的是将class1 CSS应用于外部tbody,将class2应用于内部tbody. 但是最后一个TR被认为是在外部躯干之外,因为我希望它在外部躯干内部.

My purpose is to apply class1 CSS to the outer tbody and class2 to the inner tbody. But the last TR is consider to be out of the outer tbody as I want it to be inside the outer tbody.

我该怎么做?

推荐答案

尽管这可能在实践中可行,但

While this may work in practice, it is not legal HTML.

但是,允许您在单个TABLE元素中包含多个TBODY元素,因此您可以执行以下操作:

However, you are allowed to have multiple TBODY elements in a single TABLE element, so you could do this:

<table> 
  <tbody class="show"> 
    <tr> 
      <td>...</td> 
      <td>...</td> 
    </tr> 
  </tbody>
  <tbody class="hide"> 
    <tr> 
      <td>...</td> 
      <td>...</td> 
    </tr> 
  </tbody>
  <tbody class="show"> 
    <tr> 
      <td>...</td> 
      <td>...</td> 
    </tr> 
  </tbody>
</table> 

或者,您也许可以嵌套表,尽管我并不建议这样做.

Alternatively, you may be able to nest tables, although I wouldn't really recommend that.

这篇关于一个人可以在另一个人里面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆