官术网_书友最值得收藏!

Variables

Imagine that you are coding the web page for your company; you define the style sheet, and, of course, you have a font standard color for all titles, body text, and so on. You are writing your CSS classes and notes that you need to repeat the same color value on more than one class definition. Okay, it’s not so hard to copy and paste the same value across my entire file. You finally present that web page to your UX designer and oh, surprise! That red doesn’t have to be so deep. You need to correct to the new color code. What does that mean? You will need to pe into your style sheet and manually change each color value for the new one.

Like other programming languages, with CSS preprocessors, we can define variables to reuse them across our style sheet, avoid repeating the same value, and save time when we need to adjust or change that same value. Let’s look at an example:

SASS syntax:

$my-height: 160px;

p {
height: $my-height;
}

Then, LESS syntax:

@my-height: 160px;

p {
font-size: @my-height;
}

They're pretty similar right? Let's explore other features!

主站蜘蛛池模板: 含山县| 和静县| 灵山县| 凌源市| 江安县| 托里县| 花莲市| 论坛| 焉耆| 青浦区| 神池县| 邯郸市| 师宗县| 江陵县| 双辽市| 碌曲县| 淮安市| 张家港市| 怀化市| 泽库县| 沙坪坝区| 芜湖县| 桓仁| 盱眙县| 吉林市| 阜阳市| 临泽县| 沙坪坝区| 新乡县| 农安县| 札达县| 营口市| 镇原县| 斗六市| 镇赉县| 合肥市| 奉新县| 衡南县| 马山县| 改则县| 罗田县|