[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 开发的 ...
随机推荐
- 循环神经网络(RNN, Recurrent Neural Networks)——无非引入了环,解决时间序列问题
摘自:http://blog.csdn.net/heyongluoyao8/article/details/48636251 不同于传统的FNNs(Feed-forward Neural Networ ...
- B1260 [CQOI2007]涂色paint 区间dp
这个题和我一开始想的区别不是很大,但是要我独自做出来还是有一些难度. 每一次涂色 只有这两种可能: 1) 把一段未被 覆盖过的区间 涂成 * 色 2) 把一段被一种颜色覆盖的区间涂成 * 色 (并且 ...
- 使用Azure Docker容器注册表服务
1.登录你的Azure 容器注册表服务 az acr login --name ledesign 2.给你本地准备好的Image打上上云之前的版本标签 docker tag ledesign-serv ...
- 10分钟教你Python+MySQL数据库操作
欲直接下载代码文件,关注我们的公众号哦!查看历史消息即可! 本文介绍如何利用python来对MySQL数据库进行操作,本文将主要从以下几个方面展开介绍: 1.数据库介绍 2.MySQL数据库安装和设置 ...
- Jquery 重置表单
1.重置表单回初始状态 $('#fromid')[0].reset(); 此方法一步到位,不需要一个个的去赋值为空
- python课程设计笔记(三)turtle绘图库(海龟库)
实例:绘制一条蟒蛇 #turtle:绘图库(海龟库) import turtle turtle.setup(650,350,200,200) turtle.penup() turtle.fd(-250 ...
- SEO规范(部分)
1:尽量减少AJAX的使用搜索引擎无法检索ajax中的内容,也无法识别javascript代码. 2:拒绝iframe,frame标签iframe,frame会极大的阻碍搜索引擎爬取网站内容. 3:图 ...
- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build*解决办法
easy_install -U setuptools or pip install ipython 亲测有效
- 前端-Angular思维导图笔记
看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记
- Oracle数据库实例
数据库通常由两部分组成:数据库和数据库实例 数据库与实例的关系:数据库指的是:物理数据.数据库管理系统.即物理数据.内存.操作系统.用户访问Oracle都是访问一个实例,实例名指的是用于相应某个数据库 ...