Is it bad practice to comment out single lines of CSS with //?

前端 未结 11 1714
梦如初夏
梦如初夏 2020-12-01 02:45

I have recently started using // to \"comment\" out single lines of CSS code. I understand that I am not actually commenting out the line; I am just breaking it

11条回答
  •  渐次进展
    2020-12-01 03:03

    I use // to 'comment out' lines in .css files all the time. Because it's bound to a shortcut in Vim, and I always forget what I am editing. In JavaScript it's really handy to comment out blocks of code, test the code, and 'comment in' the block of code again (shortcuts, yes).

    But when I tidy op my .css file, I use the following constructs to more easily move declarations in and out of scope:

    .pin {
        /*
        position: absolute;
        background: url(buttons-3x3.png);
        background-color: red;
        */
        height:50px;
        width:150px;
        position: relative;
    }
    
    
    .shadow {
        margin-top: 25px;
        margin-left: 25px;
        margin-left: 60px;
        width:50px;
        height:50px;
        background: url(playground.png) -400px -100px;
        position: relative;
        position: absolute;
    }
    

    In .pin I can remove a line and add it to the commented area and vice versa. In .shadow I just redeclare the same property with a different value.

    It's a pain.

    !important

提交回复
热议问题