-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: css/conditional-styling-for-unsupported-css-features.md
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Conditional Styling For Unsupported CSS Features | ||
|
||
As much as possible, you should aim to use CSS features that have broad browser | ||
support. Sometimes browsers lag behind or you'd like to take advantage of a | ||
draft feature in browsers that support it. | ||
|
||
For these situations, you can provide conditional styling using the | ||
[`@supports` at-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/@supports). | ||
|
||
Here is an example of conditionally using `display: grid` if it is supported: | ||
|
||
```css | ||
@supports (display: grid) { | ||
div { | ||
display: grid; | ||
} | ||
} | ||
``` | ||
|
||
In | ||
[this article](https://24ways.org/2019/zs-still-not-dead-baby-zs-still-not-dead/) | ||
there is an example of using `background-blend-mode` and falling back to | ||
`background-image` if it isn't supported. | ||
|
||
```css | ||
@supports not (background-blend-mode: normal) { | ||
body { | ||
background-image: url(fallback.png); | ||
} | ||
} | ||
``` |