Bar*_*kin 13 html css accessibility html-table wai-aria
在我的网页中,我需要创建一个表,该表具有根据某些用户配置可见或隐藏的标题行.此表也需要完全可访问(具体来说,因为表可能很长,我希望读取行/列标题的快捷方式可以工作).我只有ChromeVox进行测试(我将详细介绍与我发现的博客文章中其他读者的行为).
我目前的布局与此类似:
CSS:
.table-header-show {
}
.table-header-hide {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<table>
<!-- ${show} is used to choose the right class the user configuration -->
<thead class="table-header-${show}">
<tr>
<th>Name</th>
<th>Value 1</th>
<th>Value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>Value 1a</td>
<td>Value 2a</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
当标题可见时,根本没有问题.标题隐藏后,取决于屏幕阅读器是否读取这些标签:
style属性而不是a class,会导致所需的行为都起作用display: none有时会忽略内容,有时他们不会 - 所以我不确定我可以依靠这种隐藏来保证我的目的是可靠的(隐藏导航,用于标签)那么,我如何以跨浏览器阅读器的方式实现我想要的行为呢?
这可能对你有帮助。
<table>
<thead>
<tr>
<th>Name</th>
<th>Value 1</th>
<th id="foo">Value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>Value 1a</td>
<td id="foo">Value 2a</td>
</tr>
</tbody>
</table>
#foo {
visibility: collapse
}
Run Code Online (Sandbox Code Playgroud)
但关于上面提到的代码并没有所有浏览器支持。
为了改进你所拥有的,你可以table-layout: fixed在表格上使用,因为表格布局当表格单元格不是时display: none它会自动display: table-cell
| 归档时间: |
|
| 查看次数: |
4404 次 |
| 最近记录: |