Search code examples
htmlcssescapingmedia-queries

Escaping CSS in Media Query


I have a class that is just numbers, so I've used the escaping methods specified by w3 which is working as desired.

However, if I wrap it in a media query, like below, it doesn't work...

@media (min-width: 1000px) {
    .\33 47 {
        left: -115px;
    } 
}

Is there a way to use CSS escaping within a media query?


Solution

  • It works just fine. What special character are you trying to escape?

    .\26 B {
      width: 50px;
      height: 50px;
      background-color: red;
    }
    
    @media (min-width: 500px) {
      .\26 B {
        background-color: blue;
      }
    } 
    <div class="&B"></div>

    Number class:

    .\31 3 {
      width: 50px;
      height: 50px;
      background-color: #bada55;
    }
    
    @media (min-width: 500px) {
      .\31 3 {
        width: 50px;
        height: 50px;
        background-color: purple;
      }
    }
    <div class="13"></div>

    Note: check the snippet in full screen