【问题标题】:Can't parse mediaqueries with Less PHP无法使用 Less PHP 解析媒体查询
【发布时间】:2013-11-01 12:53:16
【问题描述】:

在我的 Less 文件中,我包含了一些我想在 Less 中用于媒体查询的变量:

@mobile:      ~"only screen and (max-width: 529px)";
@tablet:      ~"only screen and (min-width: 530px) and (max-width: 949px)";
@desktop:     ~"only screen and (min-width: 950px) and (max-width: 1128px)";
@desktop-xl:  ~"only screen and (min-width: 1129px)";

在我的 css 中,我会做这样的事情,例如:

@media @desktop{
    .test{
        font-size: 12px;
    }
}

当我尝试使用预处理器对其进行解析时,它会编译,但是当我使用 LessPHP 进行解析时,会出现以下错误:

PHP Fatal error:  Uncaught exception 'Exception' with message 'parse error: failed at `@media @desktop {`

【问题讨论】:

  • 我在 LessPHP 0.4.0 中在线试用了它,它编译得很好。见这里:goo.gl/swv8rp

标签: css responsive-design less media-queries lessphp


【解决方案1】:

如果你在文件的顶部放置一个虚拟规则,例如:

a {}

@mobile:      ~"only screen and (max-width: 529px)";
@tablet:      ~"only screen and (min-width: 530px) and (max-width: 949px)";
@desktop:     ~"only screen and (min-width: 950px) and (max-width: 1128px)";
@desktop-xl:  ~"only screen and (min-width: 1129px)";

@media @desktop{
    .test{
        font-size: 12px;
    }
}

在问题得到妥善解决之前,它似乎可以工作。

【讨论】:

    猜你喜欢
    • 2013-06-16
    • 1970-01-01
    • 2013-05-04
    • 2011-12-08
    • 2016-08-08
    • 1970-01-01
    • 2014-11-08
    • 2012-11-05
    • 2021-03-10
    相关资源
    最近更新 更多