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的更多相关文章

  1. [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 ...

  2. 【转】Styling And Animating SVGs With CSS

    原文转自:http://www.smashingmagazine.com/2014/11/03/styling-and-animating-svgs-with-css/?utm_source=CSS- ...

  3. 译文 对无障碍网页应用(ARIA)的选择

    //本文编辑格式为Markdown,译文同时发布在众成翻译 对无障碍网页应用(ARIA)的选择 让网站对每个人都能访问是一件相当艰难的工作,尤其是在我们使用自定义标记解决方案(custom marku ...

  4. Styling FX Buttons with CSS

    http://fxexperience.com/2011/12/styling-fx-buttons-with-css/ ——————————————————————————————————————— ...

  5. [React] Styling React Components With Aphrodite

    Aphrodite is a library styling React components. You get all the benefits of inline styles (encapsul ...

  6. (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 ...

  7. (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 ...

  8. web语义化之SEO和ARIA

    在快速理解web语义化的时候,只知道web语义化有利于SEO和便于屏幕阅读器阅读,但并不知道它是如何有利于SEO和便于阅读器阅读的,带着这个疑问,进行了一番探索总结. SEO 什么是SEO? SEO( ...

  9. ARIA无障碍技术

    ARIA Accessible Rich Internet Applications (ARIA) 规定了能够让 Web 内容和 Web 应用(特别是那些由 Ajax 和 JavaScript 开发的 ...

随机推荐

  1. 基于FPGA的VGA可移植模块终极设计【转】

    本文转载自:http://www.cnblogs.com/lueguo/p/3373643.html 略过天涯   基于FPGA的VGA可移植模块终极设计 一.VGA的诱惑 首先,VGA的驱动,这事, ...

  2. SpringBoot之表单验证@Valid

    转自:https://www.cnblogs.com/chenlove/p/8708627.html SpringBoot提供了强大的表单验证功能实现,给我们省去了写验证的麻烦: 这里我们给下实例,提 ...

  3. Spring MVC简介 2.5 Spring MVC执行的流程

    package org.fkit.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http ...

  4. thinkphp实现多数据库操作

    这篇文章主要介绍了ThinkPHP实现多数据库连接的解决方法,需要的朋友可以参考下   ThinkPHP实现连接多个数据的时候,如果数据库在同一个服务器里的话只需要这样定义模型: ? 1 2 3 cl ...

  5. POJ 2513 trie树+并查集判断无向图的欧拉路

    生无可恋 查RE查了一个多小时.. 原因是我N define的是250500 应该是500500!!!!!!!!! 身败名裂,已无颜面对众人.. 吐槽完了 我们来说思路... 思路: 判有向图能否形成 ...

  6. 【android】RxJava1原理解析

    在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...

  7. call by value 和 call by reference 的区别

    引用自https://zhidao.baidu.com/question/340173099.html Call by Value就是传值的方式,函数调用时是把实参的值传给形参,函数调用结束后形参的值 ...

  8. hdu3926 Hand in Hand 判断同构

    因为每个人小朋友只有两只手,所以每个点最多只有2度.图有可能是环.链,以及环和链构成的复杂图. 如何判断两幅图是否相似呢?判断相似是判断两幅图的圈的数量,以及构成圈的点数是否相同.还有判断链的数目和构 ...

  9. 一款APP的开发设计是如何从0到1一步一步设计的

    目前在行业里,关于APP界面设计规范也是层次不齐,很多都还停留在6的设备和ios 9的系统之上,而现在最新的是iphone 7和iOS 10了(更新换代真的很快),我这里说的是最新的iOS 界面设计规 ...

  10. 谈谈c++中继承中的虚函数

      c++继承中的虚函数 c++是一种面向对象的编程语言的一个很明显的体现就是对继承机制的支持,c++中继承分很多种,按不同的分类有不同分类方法,比如可以按照基类的个数分为多继承和单继承,可以按照访问 ...