[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 开发的 ...
随机推荐
- luogu4011 孤岛营救问题 分层图
关键词:分层图 状态压缩 最短路径 分层图:现在要求从起点到终点的最优路线,但受到手里拿着哪些钥匙的影响,最优路线不单纯了.因此,决定一个节点.一条边的存在的数中应当增加一个手中拿有钥匙的状态.这样就 ...
- 关于jetty服务器默认首页和端口设置
一.jetty服务器部署.启动成功后,在浏览器输入http://localhost:8080/ 可以直接访问到jetty欢迎首页. 这是因为在Jetty包中默认带了一个test.war的应用,在${J ...
- bzoj2958: 序列染色&&3269: 序列染色
DP这种东西,考场上就只能看命了.. #include<cstdio> #include<iostream> #include<cstring> #include& ...
- Object源码分析(二)
第五个方法:protected native Object clone() throws CloneNotSupportedException; 源码简介: clone方法首先会判对象是否实现了Clo ...
- SpringBoot中拦截器和过滤器的使用
一.拦截器 三种方式 继承WebMvcConfigurerAdapter spring5.0 以弃用,不推荐 实现WebMvcConfigurer 推荐 继承WebMvcConfiguratio ...
- NSKeyedUnarchiver归档
把自定义的类对象编码到NSData中 NSData *data = [NSKeyedArchiver archivedDataWithRootObject:bc];//归档,bc是一个自定义的类对象, ...
- 一次显式GC导致的High CPU问题处理过程
项目现场反馈系统出现性能问题,具体表现为:所有的客户端响应极其卡顿. 第一反应推测,难道是DB层面出现阻塞?检查v$session会话状态及等待类型未见异常,应该可以排除DB层面原因导致的可能. 继续 ...
- art-template简单使用
art-template是一款较通用的前端模板引擎. 简单的使用方法如下: 具备3个要素 1)模板 <script type="text/template" id=" ...
- hdu2121 Ice_cream’s world II 最小树形图(难)
这题比HDU4009要难一些.做了4009,大概知道了最小树形图的解法.拿到这题,最直接的想法是暴力.n个点试过去,每个都拿来做一次根.最后WA了,估计是超时了.(很多题都是TLE说成WA,用了G++ ...
- 文件被占用导致Hive Load文件不成功
用Python写了个用LOAD命令将文件导入Hive的程序,开始代码写成下面这样: def loadToHive(bakFilePath, tbName): try: transport = TSoc ...