Less 媒体查询和非查询

Less 媒体查询和非查询,less,media-queries,Less,Media Queries,我有以下代码: @mobile: ~'screen and (max-width: 480px)'; 然后我使用它如下: @media @mobile { // some code } 它工作得很好,但我也希望使用“not”这样的词: 但是我得到了错误 ParseError: Unrecognised input 在“不是”部分 有可能解决这个问题吗?也许你可以这样做: 定义移动设备的宽度: @mobileWidth: 480px; @notmobileWidth: @mobi

我有以下代码:

@mobile: ~'screen and (max-width: 480px)';
然后我使用它如下:

@media @mobile {  
  // some code
}
它工作得很好,但我也希望使用“not”这样的词:

但是我得到了错误

ParseError: Unrecognised input 
在“不是”部分


有可能解决这个问题吗?

也许你可以这样做:

定义移动设备的宽度:

@mobileWidth: 480px;
@notmobileWidth: @mobileWidth + 1px; 
那么任何较大的设备都是非移动设备:

@mobileWidth: 480px;
@notmobileWidth: @mobileWidth + 1px; 
为mobile和notmobile创建较少的变量:

@mobile: ~'screen and (max-width: @{mobileWidth})';
@notmobile: ~'screen and (min-width: @{notmobileWidth})';
然后在媒体查询中使用这些选项:

@media @mobile {
  // some mobile code
}

@media @notmobile {
  // some not-mobile code
}