创建跳过链接(Creating Skip Links)

优质
小牛编辑
128浏览
2023-12-01

描述 (Description)

  • 如果您的网站包含大量导航,那么屏幕阅读器通过阅读整个导航来获取网站内容有点困难。

  • 要解决此问题,您可以使用页面顶部的skip link并使用.show-on-focus类隐藏内容和tabindex = "0"属性以使元素可聚焦。

例子 (Example)

以下示例演示了在Foundation中使用skip links属性 -

<!doctype html>
   <head>
      <meta charset = "utf-8" />
      <meta http-equiv = "x-ua-compatible" content = "ie = edge" />
      <meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />
      <title>Creating Skip Links</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script>
   </head>
   <body>
      <h2>Skip Links Example</h2>
      <p><a class = "show-on-focus" href = "#myval">Skip this info</a></p>
      <main id = "myval" role = "main" tabindex = "0">
         <p>Hide Screen Readers Example</p>
      </main>
   </body>
</html>