CSS Nested Comments

后端 未结 5 561
北海茫月
北海茫月 2020-12-24 05:49

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 th

5条回答
  •  梦谈多话
    2020-12-24 06:24

    A couple years late to the party, but I seem to have stumbled on a way that seems to allow a kind of nested comment...although, as an admitted NON expert, there may be issues.

    It appears, if you just place an extra, undecorated set of braces around some css, the css inside, and even any uncommented text, is not recognized, at least by Chrome 58.0.3029.110 (64-bit):

    Original (from an unrelated question and answer):

    html, body, .container {
        height: 100%;
    }
    .container {
        display: -webkit-flexbox;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
        justify-content: center;
    }
    

    Fiddle

    With the brackets:

    html, body, .container {
        height: 100%;
    }
    { extra braces...
    .container {
        display: -webkit-flexbox;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
        justify-content: center;
    }
    /* ...act as comment? */ }
    

    Fiddle

    Kind of handy for dev work. The way I'm using this right now:

    
    

提交回复
热议问题