【问题标题】:Adding two class in an html table [duplicate]在html表中添加两个类[重复]
【发布时间】:2014-11-17 17:36:48
【问题描述】:

查看this 文章,我做了一个类(t1),以便表格在移动设备上正确定位。像这样:

/*
Label the data
*/
.t1 td:nth-of-type(1):before { content: "Name"; }
.t1 td:nth-of-type(2):before { content: "Category A"; }
.t1 td:nth-of-type(3):before { content: "Category B"; }
.t1 td:nth-of-type(4):before { content: "Category C"; }

.t2 td:nth-of-type(1):before { content: "Name"; }
.t2 td:nth-of-type(2):before { content: "Category X"; }
.t2 td:nth-of-type(3):before { content: "Category Y"; }
.t2 td:nth-of-type(4):before { content: "Category Z"; }

我还从this 网站添加了一个表格分类器,该分类器也工作正常。排序器已经有一个类(tablesorter)

当我使用以下内容时,由于 t1

,表格在移动设备上的位置正确
<table id="table1" class="t1" width="100%" border="1" >

当我使用以下内容时,由于 tablesorter

,表格正在排序
<table id="table1" class="tablesorter" width="100%" border="1" >

现在我的问题是我只能在表格中使用一个类,以便移动定位正确发生或分拣机发生。我希望两者都能发挥作用。是否可以在表中使用两个类?我读了一篇文章here,但我认为它不适用于我的问题。任何人都可以提出一种实现这一目标的方法吗?

t2 类工作正常,因为我还没有在上面放置分类器。

谢谢

编辑:它不是重复的,因为我看到一些为多个类编写的函数here 所以很困惑。然而,我现在得到了解决方案,添加了一条评论“当在移动设备上逐行查看表格时,排序功能不起作用。但它在桌面上工作!有没有办法让它在移动设备上工作? "

【问题讨论】:

  • 身份定义一次,类创建多次,用空格隔开

标签: css class html-table tablesorter


【解决方案1】:

是的,你可以。您可以为一个元素定义多个类,方法是用空格分隔它们。

<table id="table1" class="t1 tablesorter" width="100%" border="1" >

来自MDN Global Attributes Reference


此属性是元素类的空格分隔列表。

【讨论】:

  • 呸!就这么简单!!谢谢...在移动设备上逐行查看表格时,排序功能不起作用。它可以在桌面上运行!有没有办法让它在移动设备上运行?
  • @MumbaiCabinCrew,为了不混淆主题,我建议您在此处针对此特定问题打开另一个问题,并尽可能提供代码。我们很乐意提供帮助! :)
猜你喜欢
  • 2015-10-03
  • 2021-12-04
  • 2016-10-16
  • 2023-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多