* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
5.0 KiB
5.0 KiB
id, title, challengeType, videoUrl, forumTopicId, localeTitle
id | title | challengeType | videoUrl | forumTopicId | localeTitle |
---|---|---|---|---|---|
587d778d367417b2b2512aaa | Make Elements Only Visible to a Screen Reader by Using Custom CSS | 0 | https://scrimba.com/c/cJ8QGkhJ | 301020 | 使用自定义 CSS 让元素仅对屏幕阅读器可见 |
Description
.sr-only {
position: absolute;
left: -10000px;
width: 1px;
height: 1px;
top: auto;
overflow: hidden;
}
注意:
下面的 CSS 代码与上面的结果不同:
display: none;
或visibility: hidden;
会把内容彻底隐藏起来,对于屏幕阅读器也不例外。- 如果把值设置为 0px,如
width: 0px; height: 0px;
,意味着让元素脱离文档流,这样做也会让元素被屏幕阅读器忽略。
Instructions
sr-only
类,但是还没有添加 CSS 规则。请设置position
的值为 absolute,left
的值为 -10000px,width
与height
的值为 1px。
Tests
tests:
- text: '<code>sr-only</code>类中的<code>position</code>属性的值应为 absolute。'
testString: assert($('.sr-only').css('position') == 'absolute');
- text: '<code>sr-only</code>类中的<code>left</code>属性的值应为 -10000px。'
testString: assert($('.sr-only').css('left') == '-10000px');
- text: '<code>sr-only</code>类中的<code>width</code>属性的值应为 1px。'
testString: assert(code.match(/width:\s*?1px/gi));
- text: '<code>sr-only</code>类中的<code>height</code>属性的值应为 1px。'
testString: assert(code.match(/height:\s*?1px/gi));
Challenge Seed
<head>
<style>
.sr-only {
position: ;
left: ;
width: ;
height: ;
top: auto;
overflow: hidden;
}
</style>
</head>
<body>
<header>
<h1>Training</h1>
<nav>
<ul>
<li><a href="#stealth">Stealth & Agility</a></li>
<li><a href="#combat">Combat</a></li>
<li><a href="#weapons">Weapons</a></li>
</ul>
</nav>
</header>
<section>
<h2>Master Camper Cat's Beginner Three Week Training Program</h2>
<figure>
<!-- Stacked bar chart of weekly training-->
<p>[Stacked bar chart]</p>
<br />
<figcaption>Breakdown per week of time to spend training in stealth, combat, and weapons.</figcaption>
</figure>
<table class="sr-only">
<caption>Hours of Weekly Training in Stealth, Combat, and Weapons</caption>
<thead>
<tr>
<th></th>
<th scope="col">Stealth & Agility</th>
<th scope="col">Combat</th>
<th scope="col">Weapons</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Week One</th>
<td>3</td>
<td>5</td>
<td>2</td>
<td>10</td>
</tr>
<tr>
<th scope="row">Week Two</th>
<td>4</td>
<td>5</td>
<td>3</td>
<td>12</td>
</tr>
<tr>
<th scope="row">Week Three</th>
<td>4</td>
<td>6</td>
<td>3</td>
<td>13</td>
</tr>
</tbody>
</table>
</section>
<section id="stealth">
<h2>Stealth & Agility Training</h2>
<article><h3>Climb foliage quickly using a minimum spanning tree approach</h3></article>
<article><h3>No training is NP-complete without parkour</h3></article>
</section>
<section id="combat">
<h2>Combat Training</h2>
<article><h3>Dispatch multiple enemies with multithreaded tactics</h3></article>
<article><h3>Goodbye, world: 5 proven ways to knock out an opponent</h3></article>
</section>
<section id="weapons">
<h2>Weapons Training</h2>
<article><h3>Swords: the best tool to literally divide and conquer</h3></article>
<article><h3>Breadth-first or depth-first in multi-weapon training?</h3></article>
</section>
<footer>© 2018 Camper Cat</footer>
</body>
Solution
// solution required