html - Is there a way to make the tab order honour the visual order?
问题描述
Let's say I have a web page which contains a list of links.
<ul class="links">
<li><a href="#">Alpha</a></li>
<li><a href="#">Bravo</a></li>
<li><a href="#">Charlie</a></li>
</ul>
For design reasons, I need to change the order of these links on larger screens so that "Alpha" is visually at the bottom of the list.
@media (min-width: 30em) {
.links {
display: flex;
flex-direction: column;
}
.links > li:first-child {
order: 1;
}
}
When tabbing through the various focusable elements on the page, the visual order of these links is not honoured, thus when tabbing through the list the focus order will be "Alpha" then "Bravo" then "Charlie".
If I set a positive tabindex
on any of those links, they are moved to the end of the tab order (since all other focusable elements essentially have a tab index of 0
).
My question is: is there a way to make the tab order honour the visual order?.
解决方案
根据https://www.w3.org/TR/css-flexbox-1/#order-property和第 5.4.1 节,目前似乎没有办法统一 flex 排序和 HTML 排序。重新排序和可访问性:
作者必须仅将 order 用于视觉上的,而不是逻辑上的内容重新排序。使用 order 执行逻辑重新排序的样式表是不一致的。
推荐阅读
- android - Xamarin Android 绑定库不是抽象的
- php - RewriteRule 不适用于已知格式(.mp4、.mp3、.zip、.exe 和 .pdf)的文件
- coq - 证明组中的一般关联性
- mysql - 如何使用 Pomelo ORM 为 .net 核心传递 MySQL 存储过程的输出参数
- c# - .Net 项目总是重建,而不是由 CopyLocal 属性引起的最新
- javascript - ScrollView stickyHeaderIndices 道具不能按预期与多个孩子一起工作
- python - 无法将 PushKit 框架导入 pyobjus
- android - 我如何使用 ArrayList
三个字符串类型参数? - php - 如何在 php 中使用 base64_encode 从数据库中获取图像
- typescript - 如何在 Typescript 中创建静态(硬编码)嵌套数组数据