[HTML 5] Styling with ARIA
See if you can do a better job styling this button using ARIA states. One huge benefit to styling with ARIA is that it provides visual feedback that you've applied the state correctly, which can act as a safeguard when you're testing and debugging your code.
In the following code, we use js to add 'expended' class to the element. But better solution is using aria-expanded to style the element.
<button class="disclosure-button mdl-button raised" aria-expanded="false" aria-controls="content">
<span class="icon" aria-hidden="true"></span> Read More
</button>
<div id="content" class="disclosure-content hidden" aria-hidden="true">
<p>It turns out contestants who switch have a 2/3 chance of winning the car, while contestants who stick to their choice have only a 1/3 chance! <a href="https://en.wikipedia.org/wiki/Monty_Hall_problem">Curious to know more?</a></p>
</div>
if (content.getAttribute('aria-hidden') === 'true') { content.setAttribute('aria-hidden', 'false');
content.classList.remove('hidden'); button.setAttribute('aria-expanded', 'true');
button.classList.add('expanded'); } else { content.setAttribute('aria-hidden', 'true');
content.classList.add('hidden'); button.setAttribute('aria-expanded', 'false');
button.classList.remove('expanded'); }
.disclosure-button .icon::after {
content: '▶';
} .disclosure-button.expanded .icon::after {
content: '▼';
} .disclosure-content.hidden {
visibility: hidden;
opacity:;
} .disclosure-content {
visibility: visible;
opacity:;
}
Better:
.disclosure-button[aria-expanded="false"] .icon::after {
content: '▶';
} .disclosure-button[aria-expanded="true"] .icon::after {
content: '▼';
} .disclosure-content[aria-hidden="true"] {
visibility: hidden;
opacity:;
} .disclosure-content[aria-hidden="false"] {
visibility: visible;
opacity:;
}
[HTML 5] Styling with ARIA的更多相关文章
- [ARIA] Add aria-expanded to add semantic value and styling
In this lesson, we will be going over the attribute aria-expanded. Instead of using a class like .op ...
- 【转】Styling And Animating SVGs With CSS
原文转自:http://www.smashingmagazine.com/2014/11/03/styling-and-animating-svgs-with-css/?utm_source=CSS- ...
- 译文 对无障碍网页应用(ARIA)的选择
//本文编辑格式为Markdown,译文同时发布在众成翻译 对无障碍网页应用(ARIA)的选择 让网站对每个人都能访问是一件相当艰难的工作,尤其是在我们使用自定义标记解决方案(custom marku ...
- Styling FX Buttons with CSS
http://fxexperience.com/2011/12/styling-fx-buttons-with-css/ ——————————————————————————————————————— ...
- [React] Styling React Components With Aphrodite
Aphrodite is a library styling React components. You get all the benefits of inline styles (encapsul ...
- (3)选择元素——(9)为交替的列加样式(Styling alternate rows)
Two very useful custom selectors in the jQuery library are :oddand :even. Let's take a look at how w ...
- (3)选择元素——(5)为项目列表加样式(Styling list-item levels)
Let's suppose that we want the top-level items, and only the top-level items, to be arranged horizon ...
- web语义化之SEO和ARIA
在快速理解web语义化的时候,只知道web语义化有利于SEO和便于屏幕阅读器阅读,但并不知道它是如何有利于SEO和便于阅读器阅读的,带着这个疑问,进行了一番探索总结. SEO 什么是SEO? SEO( ...
- ARIA无障碍技术
ARIA Accessible Rich Internet Applications (ARIA) 规定了能够让 Web 内容和 Web 应用(特别是那些由 Ajax 和 JavaScript 开发的 ...
随机推荐
- android.mk中LOCAL_MODULE_TAGS说明【转】
转自http://blog.csdn.net/evilcode/article/details/6459299 LOCAL_MODULE_TAGS :=user eng tests optional ...
- [JXOI 2018] 游戏 解题报告 (组合数+埃氏筛)
interlinkage: https://www.luogu.org/problemnew/show/P4562 description: solution: 注意到$l=1$的时候,$t(p)$就 ...
- Hdu-6253 2017CCPC-Final K.Knightmare 规律
题面 题意:给你一个无限大的棋盘,一个象棋中的马,问你这个马,飞n步后,可能的位置有多少种? 题解:看到题,就想先打表试试,于是先写个暴力(枚举每个位置,是马就飞周围8个格子,注意不要在同个循环里把格 ...
- BPM控制控件的隐藏与显示
在BPM官方给的属性中控件属性DisplayRule中设置条件控制显示或者隐藏的时候,只能控制选中的,标题也要重新设置,这样就比较麻烦,不如自己来写javascript代码. 举一个简单的例子: 通过 ...
- 数组和String调用方法时,值是否改变(包含可变参数)
package com.wh.encapsulation; import java.util.Arrays; /** * @author 王恒 * @datetime 2017年4月5日 上午9:33 ...
- 文档控件NTKO OFFICE 详细使用说明之预览word编辑保存回服务器
1.在线预览Word文件 (1) 运行环境 ① 浏览器:支持IE7-IE11(平台版本还支持Chrome和Firefox) ② IE工具栏-Internet 选项:将www.ntko.com加入到浏览 ...
- JS中数组的一些笔记
今天工作时碰到一个需求,有两个数组arrayChild, arrayFather, 要求: 1.往数组arrayChild中放入一个元素: 2.将当前的数组arrayChild放入arrayFathe ...
- 洛谷P2391 白雪皑皑(并查集)
题目背景 “柴门闻犬吠,风雪夜归人”,冬天,不期而至.千里冰封,万里雪飘.空中刮起了鸭毛大雪.雪花纷纷,降落人间. 美能量星球(pty 在 spore 上的一个殖民地)上的人们被这美景所震撼.但是 p ...
- Javassist介绍
要想将编译时不存在的类在运行时动态创建并加载,通常有两种策略: 1. 动态编译 2. 动态生成二进制字节码(.class) 对于第二种策略,实际上已经有诸多比较成熟的开源项目提供支持,如CGLib.A ...
- vue-阻止事件冒泡-开启右键-键盘类事件
一: 阻止事件冒泡 布局: 当点击按钮时,会触发button的click 也会触发父级的方法 <div id="box"> <div @click="p ...