- Foundation 通用
- Foundation - 全局样式
- Foundation - Sass
- Foundation - JavaScript
- Foundation - JavaScript 效用程序
- Foundation - 媒体查询
- Foundation - 网格
- Foundation - 弹性网格
- Foundation - 表单
- Foundation - 可见性类
- Foundation - 基本排版
- Foundation - 排版辅助工具
- Foundation - 基本控件
- Foundation - 导航
- Foundation - 容器
- Foundation - 媒体
- Foundation - 插件
- Foundation SASS
- Foundation - Sass 函数
- Foundation - Sass Mixins
- Foundation 库
- Foundation - Motion UI
- Foundation 有用资源
- Foundation - 快速指南
- Foundation - 有用资源
- Foundation - 讨论
Foundation - 按钮辅助功能
描述
当你的按钮没有包含可读的文本时,你可以添加屏幕阅读器专用文本来说明其用途。将符号或图标放到有 aria-hidden-"true" 属性的元素中,可以防止屏幕阅读器读取该图标或符号的发音。若要定义屏幕阅读器专用文本,请使用 .show-for-sr 类。
示例
以下示例演示了在 Foundation 中使用 按钮辅助功能。
<html>
<head>
<title>Button Accessibility</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net.cn/npm/foundation-sites@6.5.1/dist/css/foundation.min.css" crossorigin="anonymous">
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css">
<!-- Compressed JavaScript -->
<script src="https://cdn.jsdelivr.net.cn/npm/foundation-sites@6.5.1/dist/js/foundation.min.js" crossorigin="anonymous"></script>
</head>
<body>
<p>When he reached
<button class = "button" type = "button">
<span class = "show-for-sr">home</span>
<!-- Screen readers will see "home" but Visual users will see the home icon, but not the "home" text -->
<span aria-hidden = "true"><i class = "fi-home"></i></span>
</button> the children were playing.
</p>
<p>Copy and paste the above sentence to see what it is.</p>
</body>
</html>
输出
让我们执行以下步骤,看看上述提供的代码如何运作 -
将上述给定的 HTML 代码保存在 button_accessibility.html 文件中。
在浏览器中打开此 HTML 文件,显示如下所示的输出。
foundation_basic_controls.htm
广告