[英]CSS comments in nested LESS rules
How can I add CSS comments in LESS nested rules? 如何在LESS嵌套规则中添加CSS注释? Ex: 例如:
div{
span{
font-size: 16px;
color: #fff;
}
/*This is my comment*/
em{
color: blue;
}
}
This is the output I expect to get: 这是我期望得到的输出:
div span {
font-size: 16px;
color: #fff;
}
/*This is my comment*/
div em {
color: blue;
}
But, unfortunatelly this is how it is processed: 但是,不幸的是,这是如何处理的:
div {
/*This is my comment*/
}
div span {
font-size: 16px;
color: #fff;
}
div em {
color: blue;
}
Is it possible to make this? 有可能做到这一点吗?
This isn't possible using /* */
. 使用/* */
是不可能的。
The reason being that it is still under the div
scope, so it won't work using /* */
comments. 原因是它仍然在div
范围内,因此不能使用/* */
注释来工作。
However, in LESS
you can use //
for single line comments which doesn't go through the compiler (so doesn't end up in the compiled CSS
code but will be in the LESS
code). 但是,在LESS
您可以将//
用于不通过编译器的单行注释(因此不会出现在已编译的CSS
代码中,而是会出现在LESS
代码中)。
Here is the official documentation on comments . 这是有关评论的官方文档 。
Well, you can get your comment inside nested rules: 好吧,您可以在嵌套规则中获取注释:
div {
em {
/* This is my comment */
color: blue;
}
}
output: 输出:
div em {
/* This is my comment */
color: blue;
}
I hope this would be useful for you. 希望对您有用。
/*This is my comment*/
div {
em {
color: blue;
}
span {
font-size: 16px;
color: #fff;
}
}
and the output will be, 输出将是
/*This is my comment*/
div em {
color: blue;
}
div span {
font-size: 16px;
color: #fff;
}
More or less it would be like what you are expecting !!! 或多或少会像您期望的那样!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.