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. 添加了click事件不响应

    https://stackoverflow.com/questions/18897807/on-click-event-on-td-created-dynamically 按照这个,给td添加clic ...

  2. oracle表类似:BIN$dJ5h8mA4Lr/gQAB/AQB0oA==$0 TABLE

    今天看到数据库中有很多类似: TNAME                          TABTYPE  CLUSTERID ------------------------------ ---- ...

  3. wamp服务器下安装mantis

    什么是Mantis Mantis是一个BUG管理系统.主要特点如下: 1.用php写的系统,安装方便,不用像 bugzilla 那样安装那么多perl支持: 2.系统相对简单轻磅,使用简单: 3.出色 ...

  4. ffmpeg实现

    最近做一个小项目,要在线播放录制的 MP4 视频,想开源的 flash player 或 html 5 可以播放.可,虽然 MP4 是 H.264 编码,但就是播放不了.可能是封装方式(PS 方式)不 ...

  5. Python基础教程思维导图笔记

    说明:直接查看图片可能不太清楚,用浏览器打开后,按住 Ctrl ,网上滚动鼠标放大浏览器页面,可以看清楚图片

  6. The name ‘InitialzeComponent’ does not exist in the current context

    在Visual Studio中创建Windows Store项目,在MainPage.xaml.cs中出现错误: The name 'InitialzeComponent' does not exis ...

  7. 用命令行在本地创建一个库并上传到Github

    1  如何在本地创建一个仓库并上传到github? 基本步骤: $ mkdir blog //在桌面上创建一个叫"blog"的目录 $ cd blog //"cd blo ...

  8. 大白话理解this

    日常开发中,我们经常用到this.一开始常会用一种感觉去判断this的指向,当遇到复杂的函数调用时,就分不清this的指向. 今天我们来由浅入深来学习下. function family1(){ va ...

  9. HDFS开发中的一些问题(逐步补充)

    1.windows操作系统下运行时报:Failed to locate the winutils binary in the hadoop binary path   java.io.IOExcept ...

  10. 一个关于C++拷贝构造的bug

    #include <iostream> using namespace std; class A { public: A(int a) {}; A(const A&) = defa ...