CSS pre-processor with a possibility to define variables in a @media query

后端 未结 3 1465
悲&欢浪女
悲&欢浪女 2020-12-17 18:35

Currently, I am using LESS as my main CSS pre-processor. I have (and I am sure a lot of people have this need) to define variables in a @media query like:

3条回答
  •  攒了一身酷
    2020-12-17 18:59

    what about:

    @media screen and (max-width: 479px) {
        .myElement(10px);
    }
    
    @media screen and (min-width: 768px) {
        .myElement(30px);
    }
    
    
    .myElement(@myVar) {
        .myElement {
            padding: @myVar;
        }
    }
    

提交回复
热议问题