Php Can';t在响应表格布局中显示表格标题

Php Can';t在响应表格布局中显示表格标题,php,html,css,wordpress,Php,Html,Css,Wordpress,我使用下面提到的代码在WordPress post中显示表格。它正确地显示了表格,但我想使其具有响应性,所以,我使用自定义CSS代码来制作响应性表格布局。它正在工作,但在调整页面布局时缺少表头。谁能给我指路吗 $menu .= '<table><thead><tr><th>Name</th><th>Description</th><th>Price</th></tr></

我使用下面提到的代码在WordPress post中显示表格。它正确地显示了表格,但我想使其具有响应性,所以,我使用自定义CSS代码来制作响应性表格布局。它正在工作,但在调整页面布局时缺少表头。谁能给我指路吗

$menu .= '<table><thead><tr><th>Name</th><th>Description</th><th>Price</th></tr></thead>';
                while ( have_rows('sections_items') ) : the_row();
                        // Your loop code
                        $menu .= '<tr><td>'.get_sub_field('dish_names').'</td><td>'.get_sub_field('dish_description').'</td><td>$ '.get_sub_field('dish_price').'</td></tr>';
                    endwhile;
                $menu .= '</table> ';
/*css结束*/这是我得到的表外信息


看起来代码成功地隐藏了现有的thead/th标记,并将tr和td标记从行交换到列,反之亦然。也许您可以在CSS中使用:before在每个表中的相应td标记之前重新添加标题信息。我在CSS的末尾添加了以下内容(在最后两个弯曲的括号之前):

td:nth-of-type(1):before { content: "Name"; }
td:nth-of-type(2):before { content: "Description"; }
td:nth-of-type(3):before { content: "Price"; }
我认为,如果不能接受将其编码到CSS中,您也可以从Javascript中更改这些内容


以下是JSFIDLE:

生成的源代码中是否显示了
?我使用ACF在WordPress中显示表格。但我想添加CSS以使表格响应。但是缺少表格标题可能您缺少
生成
的逻辑是什么{width:1px;height:1px;position:absolute;}
?仍然无法获取表格标题。
td:nth-of-type(1):before { content: "Name"; }
td:nth-of-type(2):before { content: "Description"; }
td:nth-of-type(3):before { content: "Price"; }