35 lines
805 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 5a9d726c424fe3d0e10cad11
title: 创建一个自定义的 CSS 变量
challengeType: 0
videoUrl: 'https://scrimba.com/c/cQd27Hr'
forumTopicId: 301086
---
# --description--
创建一个 CSS 变量,你只需要在变量名前添加两个`破折号`,并为其赋值,例子如下:
```css
--penguin-skin: gray;
```
这样会创建一个`--penguin-skin`变量并赋值为`gray灰色`。 现在,其他元素可通过该变量来设置为`gray灰色`
# --instructions--
`penguin`class 里面,创建一个`--penguin-skin`变量,且赋值为`gray灰色`
# --hints--
`penguin` class 里应声明`--penguin-skin`变量,且赋值为`gray`
```js
assert(
code.match(/.penguin\s*?{[\s\S]*--penguin-skin\s*?:\s*?gray\s*?;[\s\S]*}/gi)
);
```
# --solutions--