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.
- HCNA網絡技術
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- Wireshark網絡分析就這么簡單
- Mastering JavaFX 10
- 數字調制解調技術的MATLAB與FPGA實現:Altera/Verilog版(第2版)
- Spring 5.0 Projects
- 通信原理及MATLAB/Simulink仿真
- 紅藍攻防:構建實戰化網絡安全防御體系
- 6G無線網絡空口關鍵技術
- 端到端QoS網絡設計
- 網絡利他行為研究:積極心理學的視角
- 圖神經網絡前沿
- Hands-On Reactive Programming in Spring 5
- 智能物聯網:區塊鏈與霧計算融合應用詳解
- 物聯網傳感器技術與應用