我正在阅读本教程here。在其中一个示例中,有一个CSS类定义,如:
**
* A mixin which helps you to add depth to elements according to the Google Material Design spec:
* http://www.google.com/design/spec/layout/layout-principles.html#layout-principles-dimensionality
*
* Please note that the values given in the specification cannot be used as is. To create the same visual experience
* the blur parameter has to be doubled.
*
* Author: Florian Kutschera (@gefangenimnetz), Conceptboard GmbH (@conceptboardapp)
*
* Example usage:
*
* .card {
* width: 95px;
* height: 95px;
* background: #f4f4f4;
* -webkit-transition: all 250ms;
* -moz-transition: all 250ms;
* transition: all 250ms;
* .BoxShadowHelper(1);
* &:hover {
* .BoxShadowHelper(3);
* -webkit-transform: translateY(-5px);
* -moz-transform: translateY(-5px);
* transform: translateY(-5px);
* }
* }
*
*/
.BoxShadowHelper(@level: 1){
& when (@level = 1) {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
& when (@level = 2) {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
& when (@level = 3) {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
& when (@level = 4) {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
& when (@level = 5) {
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
}
}
我......好吧,我们不知道我们可以用课程来做到这一点。我试图寻找更多信息,但是" CSS条件逻辑"什么都搞不了。我在这里找到了this question,关于@符号,但是当我查找more information时,它似乎与此代码段无关。
"条件CSS"提出this,this以及有关为IE包含样式表的更多问题。
我只是想知道我在.BoxShadowHelper和.card中看到了什么,我可以在哪里了解更多信息!
答案 0 :(得分:3)
这不是 vanilla CSS,这很少。
具体而言,那些@level = 1
是LESS' Guard Comparison Operators
。请参阅此处的文档http://lesscss.org/features/#mixin-guards-feature-guard-comparison-operators