2.5 KiB
2.5 KiB
id | title | challengeType | videoUrl |
---|---|---|---|
5b7d72c338cd7e35b63f3e14 | Improve Compatibility with Browser Fallbacks | 0 |
Description
Instructions
.red-box
class. Let's improve our browser compatibility by adding another background
declaration right before the existing declaration and set its value to red.
Tests
tests:
- text: Your <code>.red-box</code> rule should include a fallback with the <code>background</code> set to red immediately before the existing <code>background</code> declaration.
testString: assert(code.match(/.red-box\s*{[^}]*background:\s*(red|#ff0000|#f00|rgb\(\s*255\s*,\s*0\s*,\s*0\s*\)|rgb\(\s*100%\s*,\s*0%\s*,\s*0%\s*\)|hsl\(\s*0\s*,\s*100%\s*,\s*50%\s*\))\s*;\s*background:\s*var\(\s*--red-color\s*\);/gi), 'Your <code>.red-box</code> rule should include a fallback with the <code>background</code> set to red immediately before the existing <code>background</code> declaration.');
Challenge Seed
<style>
:root {
--red-color: red;
}
.red-box {
background: var(--red-color);
height: 200px;
width:200px;
}
</style>
<div class="red-box"></div>
Solution
var code=".red-box {background: red; background: var(--red-color);}"