简体   繁体   English

CSS嵌套注释多行代码注释其他注释内部

[英]CSS Nested Comment Multiline Code Comment Inside Other Comment

Inside a CSS file I've got 2 ways to format a body element. 在CSS文件中,我有2种格式化body元素的方式。 How can I comment to select body style 1? 如何评论以选择身体样式1?

/* body style 1 */
body {
  background-color: #E6F6F6; /* color 1 */
}

/* I want to comment all from here to end */
/*
/* body style 2 */
body {
  background-color: #F6F6F6; /* color 2 */
} /* this right bracket is not commented out */
p {
    font-size: 10px;
}
*/

CSS comments run until the first instance of */. CSS注释一直运行到* /的第一个实例。 You cannot nest CSS comments. 您不能嵌套CSS注释。

You could do something like this, but it's messy: 您可以做这样的事情,但是很麻烦:

/* body style 1 */
body {
  background-color: #E6F6F6; /* color 1 */
}

/* I want to comment all from here to end */
/*
/* body style 2 */
/*body {
  background-color: #F6F6F6; /* color 2 */
/* } /* this right bracket is not commented out */
p {
    font-size: 10px;
}
*/

remove the /*color 2*/ comment and additional comments and then it will work 删除/*color 2*/注释和其他注释,然后它将起作用

/* body style 1 */
body {
  background-color: #E6F6F6; 
}

/* I want to comment all from here to end */

/* body style 2 */
/*
body {
  background-color: #F6F6F6; 
} 
p {
    font-size: 10px;
}
*/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM