CSS嵌套注释 [英] CSS Nested Comments
问题描述
有没有办法在CSS中嵌入注释?
Is there any way to nest comments in CSS?
例如,当我尝试注释掉以下两个语句时,外部注释在遇到
For example, when I try to comment out the following two statements, the outer comment ends when it encounters the */ in the nested comment, leaving the rest of the first statement and second statement uncommented.
/*
#container {
width: 90%; /* nested comment here */
margin: 0 auto;
}
#container .class {
width: 25%;
}
*/
尝试一种包含多个语句的不同造型技术。
I run into this problem often when I want to try out a different styling technique that involves multiple statements.
我熟悉CSS 规范(用于评论)及其理由,但也知道有一个解决方法用于嵌套
I'm familiar with the CSS specification for comments and its rationale, but also know there's a workaround for nesting HTML comments and am hoping there's a similar hack for CSS.
有没有人在CSS中嵌入注释?
Has anyone found a way to nest comments in CSS?
推荐答案
您可以将规则包裹在嵌套的某些内容中,例如不存在的媒体类型:
You could instead wrap the rules in something which does nest, such as a non-existent media type:
@media DISABLED {
#container {
width: 90%; /* nested comment here */
margin: 0 auto;
}
#container .class {
width: 25%;
}
}
这篇关于CSS嵌套注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!