Scss variable

In last section, we put the @media inside a nested selectors in different groups. This leads to an issue that our breakport, 500px, is difined in more than one place.

Preprocessor allows us to define variable. Here is an example of using Scss that define 2 variables, breakpont and the major color.

 1$breakpoint: 500px;
 2$major-color: steelblue;
 3
 4body > header,
 5body > footer {
 6    background: $major-color;
 7}
 8
 9@media screen and (min-width: $breakpoint) {
10  .one {
11    width: 25%;
12  }
13  .two {
14    width: 50%;
15  }
16  .three {
17    width: 75%;
18  }
19  .four {
20  }
21}

What’s next? We’re going to take a look at “Scss mixin”.

overlaied image when clicked on thumbnail

Makzan | Mobile web design | Table of Content