【问题标题】:SASS error : Invalid CSS after "": expected media query list, was ""only screen an..."SASS 错误:“”后的 CSS 无效:预期的媒体查询列表,是“”仅屏幕...”
【发布时间】:2020-08-05 13:11:59
【问题描述】:

如果我调用 SASS 命令如下所示:

call sass C:\Users\simon\source\repos\Pippo\ClickR\\Styles\main.scss C:\Users\simon\source\repos\Pippo\ClickR\\Styles\main.css

我收到以下错误:

Error: Invalid CSS after "": expected media query list, was ""only screen an..."
    on line 348 of C:/Users/simon/source/repos/Pippo/ClickR/Styles/foundation/components/_top-bar.scss
    from line 22 of C:/Users/simon/source/repos/Pippo/ClickR/Styles/_foundation.scss
    from line 3 of C:\Users\simon\source\repos\Pippo\ClickR\\Styles\main.scss
    Use --trace for backtrace.

这是产生错误的代码:

_top-bar.scss

....
$topbar-media-query: "only screen and (min-width:"#{$topbar-breakpoint}")" !default;
....
@media #{$topbar-media-query} {
.top-bar {
  background: $topbar-bg;
  @include clearfix;
  overflow: visible;

  .toggle-topbar { display: none; }

  .title-area { float: $default-float; }
  .name h1 a { width: auto; }

  input,
  .button {
    line-height: 2em;
    font-size: emCalc(14px);
    height: 2em;
    padding: 0 10px;
    position: relative;
    top: 8px;
  }

  &.expanded { background: $topbar-bg; }
}
....

我该如何解决? 谢谢, 西蒙娜

【问题讨论】:

  • 您应该包含有问题的 SCSS 文件的内容。

标签: ruby sass stylesheet


【解决方案1】:

问题只是分配给$topbar-media-query 的语法错误。

你应该在字符串中转义双引号,或者你应该使用single quote

在您的示例中,CSS property min-width 不需要字符串,因此更简单的做法是:

代替

$topbar-media-query: "only screen and (min-width:"#{$topbar-breakpoint}")" !default;

试试

$topbar-media-query: "only screen and (min-width:#{$topbar-breakpoint})" !default;

【讨论】:

  • 您应该详细说明您的答案如何解决导致意外行为的问题。
  • @pdoherty926 完成。谢谢,我认为在这种简单的情况下,解决方案是不言自明的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-01-26
  • 2017-01-06
  • 2011-12-06
  • 2012-11-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多