2018-12-25 07:29:00 +02:00
|
|
|
---
|
|
|
|
title: Improve Compatibility with Browser Fallbacks
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Improve Compatibility with Browser Fallbacks
|
2018-12-25 07:29:00 +02:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Problem Explanation
|
2018-12-25 07:29:00 +02:00
|
|
|
We need to add a fallback to the ```background``` property of the ```.black-box`` class.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
**Example:**
|
2018-12-25 07:29:00 +02:00
|
|
|
|
|
|
|
```css
|
|
|
|
:root {
|
|
|
|
--black-color: black;
|
|
|
|
}
|
|
|
|
.black-box {
|
|
|
|
background: var(--black-color);
|
|
|
|
width: 100px;
|
|
|
|
height: 100px;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
2018-12-25 07:29:00 +02:00
|
|
|
|
|
|
|
Add a fallback to the ```background``` property before the existing background declaration:
|
|
|
|
|
|
|
|
```css
|
|
|
|
:root {
|
|
|
|
--black-color: black;
|
|
|
|
}
|
|
|
|
.black-box {
|
|
|
|
background: black;
|
|
|
|
background: var(--black-color);
|
|
|
|
width: 100px;
|
|
|
|
height: 100px;
|
|
|
|
}
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|
2018-12-25 07:29:00 +02:00
|
|
|
|