Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.

Commit b090e8b

Browse files
joshallingscissorsneedfoodtoo
authored andcommitted
feat(challenges): add browser fallback challenge
ISSUES CLOSED: freeCodeCamp/freeCodeCamp#17546
1 parent 72c2407 commit b090e8b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

challenges/01-responsive-web-design/basic-css.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5546,6 +5546,51 @@
55465546
}
55475547
}
55485548
},
5549+
{
5550+
"id": "5b7d72c338cd7e35b63f3e14",
5551+
"title": "Improve Compatibility with Browser Fallbacks",
5552+
"description": [
5553+
"When working with CSS you will likely run into browser compatibility issues at some point. This is why it's important to provide browser fallbacks to avoid potential problems.",
5554+
"When your browser parses the CSS of a webpage, it ignores any properties that it doesn't recognize or support. For example, if you use a CSS variable to assign a background color on a site, Internet Explorer will ignore the background color because it does not support CSS variables. In that case, the browser will use whatever value it has for that property. If it can't find any other value set for that property, it will revert to the default value, which is typically not ideal.",
5555+
"This means that if you do want to provide a browser fallback, it's as easy as providing another more widely supported value immediately before your declaration. That way an older browser will have something to fall back on, while a newer browser will just interpret whatever declaration comes later in the cascade.",
5556+
"<hr>",
5557+
"It looks like a variable is being used to set the background color of the <code>.red-box</code> class. Let's improve our browser compatibility by adding another <code>background</code> declaration right before the existing declaration and set its value to red."
5558+
],
5559+
"tests": [
5560+
{
5561+
"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.",
5562+
"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.');"
5563+
}
5564+
],
5565+
"solutions": [
5566+
"var code=\".red-box {background: red; background: var(--red-color);}\""
5567+
],
5568+
"challengeType": 0,
5569+
"translations": {},
5570+
"files": {
5571+
"indexhtml": {
5572+
"key": "indexhtml",
5573+
"ext": "html",
5574+
"name": "index",
5575+
"contents": [
5576+
"<style>",
5577+
" :root {",
5578+
" --red-color: red;",
5579+
" }",
5580+
" .red-box {",
5581+
" ",
5582+
" background: var(--red-color);",
5583+
" height: 200px;",
5584+
" width:200px;",
5585+
" }",
5586+
"</style>",
5587+
"<div class=\"red-box\"></div>"
5588+
],
5589+
"head": [],
5590+
"tail": []
5591+
}
5592+
}
5593+
},
55495594
{
55505595
"id": "5a9d7295424fe3d0e10cad14",
55515596
"title": "Cascading CSS variables",

0 commit comments

Comments
 (0)