- 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/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/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
廣告