Can we have multiple <tbody> tags in same <table>? If yes then in what scenarios should we use multiple <tbody> tags?

我们可以有多个标签相同的

吗?如果是,那么在什么情况下我们应该使用多个 标记?

8 个解决方案

#1


625

Yes you can use them, for example I use them to more easily style groups of data, like this:

是的,你可以使用它们,例如我用它们来更容易的样式组数据,像这样:

<table>
    <thead>
        <tr><th>Customer</th><th>Order</th><th>Month</th></tr>
    </thead>
    <tbody>
        <tr><td>Customer 1</td><td>#1</td><td>January</td></tr>
        <tr><td>Customer 1</td><td>#2</td><td>April</td></tr>
        <tr><td>Customer 1</td><td>#3</td><td>March</td></tr>
    </tbody>
    <tbody>
        <tr><td>Customer 2</td><td>#1</td><td>January</td></tr>
        <tr><td>Customer 2</td><td>#2</td><td>April</td></tr>
        <tr><td>Customer 2</td><td>#3</td><td>March</td></tr>
    </tbody>
    <tbody>
        <tr><td>Customer 3</td><td>#1</td><td>January</td></tr>
        <tr><td>Customer 3</td><td>#2</td><td>April</td></tr>
        <tr><td>Customer 3</td><td>#3</td><td>March</td></tr>
    </tbody>
</table>

Then you can style them easily, like this:

然后你可以很容易地把它们设计成这样:

tbody:nth-child(odd) { background: #f5f5f5; }
tbody:nth-child(even) { background: #e5e5e5; }

You can view an example here, it'll only work in newer browsers...but that's what I'm supporting in my current application, you can use the grouping for JavaScript etc. The main thing is it's a convenient way to visually group the rows to make the data much more readable. There are other uses of course, but as far as applicable examples, this one is the most common one for me.

您可以在这里查看一个示例,它只在较新的浏览器中工作……但这就是我在当前的应用程序中支持的,你可以使用JavaScript的分组等等。主要的是,这是一种方便的方式来直观地组织行,使数据更容易阅读。当然还有其他的用法,但在适用的例子中,这个是最常见的。

更多相关文章

  1. AngularJS使用双向数据绑定将img元素标签中的图像显示为源?
  2. Ajax技术--服务器返回数据格式(HTML,XML,JSON)
  3. HTML+jQuery图片上传示例
  4. 扩展htmlhelper.DropDownListFor 支持list数据源和option增加属
  5. java中json数据格式的应用
  6. 我使用生成html文件的python制作了一个脚本。如何使用Web爬网程
  7. 关于解析html并使用shell提取数据
  8. 【网络爬虫】【java】微博爬虫(四):数据处理——jsoup工具解析html
  9. 【ASP.NET Web API教程】5.2 发送HTML表单数据:URL编码的表单数据

随机推荐

  1. 【Android】 基于XMPP Smack框架 开发QQ
  2. 一样的Android,不一样的学习
  3. Android平台开发指导(Android Porting Gui
  4. 新书内容连载(1):自定义Android组件之带图像
  5. Android工具箱之文件目录
  6. hello world 第一个android程序
  7. Android数据加密之Rsa加密
  8. C#开发Android应用的必备——Mono for An
  9. Android(安卓)应用设置全局Exception处理
  10. Android布局控件属性