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. element-UI中table表格的@row-click事件和@selection-change耦合了

    <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark&quo ...

  2. 利用Powershell和ceye.io实现Windows账户密码回传

    利用Powershell和ceye.io实现Windows账户密码回传 转自:http://www.freebuf.com/articles/system/129068.html 最近在研究Power ...

  3. React-Native Android开发沉思录

    在runServer.js中有声明如何启动http服务: 查看端口占用情况 而且在系统管理器中,根本找不到PID为7956的应用,那能更改端口吗?在server.js中有声明: module.expo ...

  4. C++字符串与指针 所有的内容也就这么多了。

    1.定义一个字符串数组并初始化,然后输出其中的字符串. #include <iostream> using namespace std;int main(){ char str[]=&qu ...

  5. Docker修改hosts方法

    方法一: 直接进入容器中修改/etc/hosts 缺点:重启容器后,增加的内容会丢失 方法二: 制作镜像的时候,直接修改. 限制: 需要是root用户,需要在容器中安装sudo 增大了镜像大小 方法三 ...

  6. nRF52832添加微信硬件接入服务AirSync

    开发环境 SDK版本:nRF5_SDK_15.0.0 芯片:nRF52832-QFAA OS: FreeRTOS 10.0.0 测试APP:AirSyncDebugger  https://iot.w ...

  7. 利用网络Socket和多线程实现一个双向聊天

    接收键盘输入然后向对方发送消息的线程 package cn.com.chat; import java.io.BufferedReader; import java.io.BufferedWriter ...

  8. openssl https证书

    今天摸索了下 HTTPS 的证书生成,以及它在 Nginx 上的部署.由于博客托管在 github 上,没办法部署证书,先记录下,后续有需要方便快捷操作.本文的阐述不一定完善,但是可以让一个初学者了解 ...

  9. jah老师中关于集合的总结

    --------概述:1.Java 集合就像一种容器,可以把多个对象的引用放入容器中 2.Java 集合类可以用于存储数量不等的多个对象,还可用于保存具有映射关系的关联数组3.Java 集合可分为 S ...

  10. DDL:对表___table___的相关操作

    1) 增加列 语法: alter table 表名 add 列名 类型(长度) 约束; 2) 修改现有列类型.长度和约束 语法:alter table 表名 modify 列名 类型(长度) 约束; ...