跨浏览器,无Javascript,Skip Navigation Link

Bar*_*art 6 html accessibility cross-browser

在最近搜索Skip Navigation链接的最佳实践时,这是我能找到的最全面的解决方案:http://www.communis.co.uk/blog/2009-06-02-skip-links-chrome-safari-和添加的纬-咏叹调

我不喜欢这个,它需要在Webkit浏览器上使用JavaScript.这真的是我们对看似简单的跳过导航链接的最佳解决方案吗?

有任何链接或样本谈论其他"更好"的解决方案吗?

zzz*_*Bov 1

我倾向于使用

#skip-to-nav, #skip-to-content
{
  position: absolute;
  right: 100%;
}
Run Code Online (Sandbox Code Playgroud)

我确保 #skip-to-nav 和 #skip-to-content 链接位于该body元素中。

Drupal 7 用途:

/**
 * Hide elements visually, but keep them available for screen-readers.
 *
 * Used for information required for screen-reader users to understand and use
 * the site where visual display is undesirable. Information provided in this
 * manner should be kept concise, to avoid unnecessary burden on the user.
 * "!important" is used to prevent unintentional overrides.
 */
.element-invisible {
  position: absolute !important;
  clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  clip: rect(1px, 1px, 1px, 1px);
}

/**
 * The .element-focusable class extends the .element-invisible class to allow
 * the element to be focusable when navigated to via the keyboard.
 */
.element-invisible.element-focusable:active,
.element-invisible.element-focusable:focus {
  position: static !important;
  clip: auto;
}
Run Code Online (Sandbox Code Playgroud)

我已经用屏幕阅读器测试了这两种方法,对于看不到屏幕的人来说,它们似乎都能正常工作。

就 Tab 键顺序而言,我不担心用户按 Tab 键切换到他们看不到的元素。我可能应该这样做,但我发现绝大多数用户无论如何都不使用 Tab 键。那些确实这样做的人往往更了解正在发生的事情,所以恕我直言,它变得毫无意义。

编辑添加:

经过与 @discojoe 的讨论后,我决定更仔细地了解 drupal 7 用于隐藏/显示内容的内容,我相应地更新了代码。