[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 开发的 ...
随机推荐
- 0x66 Tarjan算法与无向图联通性
bzoj1123: [POI2008]BLO poj3694 先e-DCC缩点,此时图就变成了树,树上每一条边都是桥.对于添加边的操作,相当于和树上一条路径构环,导致该路径上所有边都不成为桥.那么找这 ...
- bzoj5029: 贴小广告&&bzoj5168: [HAOI2014]贴海报
以后做双精题请至少先跑个数据...输入都不一样... 做法就是离散化大力线段树. 记得在x+1和y-1插点 看这个数据: 1000 121 10050 8080 9950 981 56100 2002 ...
- CodeForces--621A--Wet Shark and Odd and Even(数学水题)
Wet Shark and Odd and Even Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & ...
- lightoj--1005--Rooks(组合数)
Rooks Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Status De ...
- 使用fastcgi部署django应用
1.fastcgi和cgi的区别 1)CGI (Common Gateway Interface): 用来作为 Web Server 同 Python, PHP 等的通信手段.而在静态网页的时代, 只 ...
- hammer教程
一.前言 移动端框架当前还处在初级阶段,但相对于移动端的应用来说已经有很长时间了.虽然暂时还没有PC端开发的需求量大,但移动端的Web必然是一种趋势,在接触移动端脚本的过程中,最开始想到的是juqer ...
- ROS-TF-广播
前言:将海龟的坐标系变换广播到TF. URDF文件的描述是在相对坐标上进行的,运动起来就需要考虑机器人各个连杆的相对位置关系.TF的诞生就是为了自动管理这些相对关系下的坐标变换的,而我们需要做的就是给 ...
- 3.ThinkPHP入门---视图
视图:MVC三大组成部分,负责信息的展示和输出 1.视图的创建 创建的位置需要是在分组目录下的view目录下余控制器同名的目录中. 2.视图的展示 在smarty和tinkphp都是使用diaplay ...
- DB2大数据量优化查询解决方案
利用DB2表分区的功能对大数据量的表进行分区,可以优化查询. 表分区介绍: 表分区是一种数据组织方案,它根据一列或多列中的值把表数据划分为多个称为数据分区 的存储对象. (我觉得表分区就类似于Wind ...
- showdialog
在C#中窗口的显示有两种方式:模态显示(showdialog)和非模态显示(show). 区别: 模态与非模态窗体的主要区别是窗体显示的时候是否可以操作其他窗体.模态窗体不允许操作其他窗体,非模态窗体 ...