--- id: 5a9d72a1424fe3d0e10cad15 title: 更改特定區域的變量 challengeType: 0 videoUrl: 'https://scrimba.com/c/cdRwbuW' forumTopicId: 301085 dashedName: change-a-variable-for-a-specific-area --- # --description-- 當你在 `:root` 裏創建變量時,這些變量的作用域是整個頁面。 然後,你可以通過在一個特定的選擇器中再次設置這些變量來重寫這些變量。 # --instructions-- 在 `penguin` class 裏,請設置 `--penguin-belly` 的值爲 `white`。 # --hints-- 應在 `penguin` class 裏重定義 `--penguin-belly` 的變量值,新的值應爲 `white`。 ```js assert( code.match(/\.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi) ); ``` `penguin` 類不應包含 `background-color` 屬性。 ```js assert( code.match(/^((?!background-color\s*?:\s*?)[\s\S])*$/g) ); ``` # --seed-- ## --seed-contents-- ```html