Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

1.5 KiB

title
title
Change a variable for a specific area

Change a variable for a specific area


Problem Explanation

Cascading CSS variables officially called custom properties are entities which behave similarly to traditional variables. In that variables allow for data to be stored and updated to reflect new values later.

When maintaining complex CSS documents, it is not only beneficial to use CSS Variables but also smart. When making future updates instead of searching potential hundreds of lines of code, one only needs to update the necessary CSS variable.

Example Syntax:

Declaring the variable:

--custom-name: value

Using the variable:

var(--custom-name)

Solutions

Solution 1 (Click to Show/Hide)

We need to reassign the --penguin-belly variable to white in the penguin class:

  .penguin {
    /* add code below */
    --penguin-belly: white;
    /* add code above */
    position: relative;
    margin: auto;
    display: block;
    margin-top: 5%;
    width: 300px;
    height: 300px;
  }
  1. Visit MDN's Cascading CSS Variables page for more information.
  2. Perna, Maria Antonietta. "A Practical Guide to CSS Variables (Custom Properties)" sitepoint. August 01, 2018. Accessed: October 5, 2018