- Hands-On Full Stack Web Development with Aurelia
- Diego Jose Argüelles Rojas Erikson Haziz Murrugarra Sifuentes
- 219字
- 2021-06-25 20:58:25
Nesting
Nesting elements in pure CSS are a bad deal. They are not friendly, are hard to read, and make us write and repeat a lot of code. Using a CSS preprocessor, you will provide a more friendly reading to any developer; the code auto explains what the CSS is doing and how the classes inherit from others. Look at the magic:
Using the SASS syntax:
$my-link-color: #FF0000;
$my-link-hover: #00FFFF;
ul {
margin: 0;
li {
float: left;
}
a {
color: $my-link-color;
&:hover {
color: $my-link-hover;
}
}
}
Using the same in LESS:
@my-link-color: #FF0000;
@my-link-hover: #00FF00;
ul {
margin: 0;
li {
float: left;
}
a {
color: @my-link-color;
&:hover {
color: @my-link-hover;
}
}
}
One thing you need to know is that the browser does not directly interpret the SASS or LESS syntax. Do you need to convert your code to normal CSS syntax, how could you perform it? In the case of SASS, just type the following command:
$ sass --watch app/sass:public/stylesheets
They both export the same CSS output:
ul { margin: 0; }
ul li { float: left; }
ul a { color: #999; }
ul a:hover { color: #229ed3; }
As you can see, CSS preprocessors provide us a more friendly readability and quick understanding of what the code is doing.
- 智慧城市:大數(shù)據(jù)、互聯(lián)網時代的城市治理(第4版)
- Modern JavaScript Web Development Cookbook
- 物聯(lián)網安全(原書第2版)
- Building E-commerce Sites with VirtueMart Cookbook
- 網管員典藏書架:網絡管理與運維實戰(zhàn)寶典
- 工業(yè)控制網絡安全技術與實踐
- Hands-On Chatbots and Conversational UI Development
- Drush User’s Guide
- 電力物聯(lián)網工程技術原理與應用
- 邁向自智網絡時代:IP自動駕駛網絡
- Bonita Open Solution 5.x Essentials
- 網管工具使用與技巧大全
- 網絡AI+:2030后的未來網絡
- 從實踐中學習手機抓包與數(shù)據(jù)分析
- 一本書讀懂物聯(lián)網