【问题标题】:SASS won't compile WordPress stylesheet because of comments由于评论,SASS 不会编译 WordPress 样式表
【发布时间】:2014-08-08 02:00:36
【问题描述】:

我正在使用 Koala 自动编译 style.sass,显然它不喜欢文件开头所需的多行 cmets(即:/* Theme Name:...*/)。

每次尝试编译时都会出错:

style.sass 第 2 行的警告: 这个选择器没有任何属性并且不会被渲染。 style.sass 第 3 行的警告: 这个选择器没有任何属性并且不会被渲染。 style.sass 第 5 行的警告: 这个选择器没有任何属性并且不会被渲染。 语法错误:“...nsive,modern,”后的 CSS 无效:预期表达式(例如 1px,粗体)是“和优雅的婚礼...” 在 style.sass 的第 6 行

我应该只编译它然后将多行 cmets 添加到压缩的 style.css 中吗?那会很头疼。

似乎因为 cmets 有一个“:”它认为它是一个 css 属性。

编辑,代码如下:

/*
Theme Name: ...
Theme URI: ...
Author: ...
Author URI: ...
Description: A responsive, modern, and elegant wedding theme.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: ...
*/


// Micro Clearfix //

.cf:before,
.cf:after 
    content: " " // 1
    display: table // 2

.cf:after
    clear: both

// For IE 6/7 only. Include this rule to trigger hasLayout and contain floats.
.cf
    *zoom: 1


// Defaults //

html,
body
    font-size: 100%
    width: 100%


// SASS Variables //

$fuchsia: #fe4365
$pink: #fc9d9a
$salmon: #f9cdad
$olive: #c8c8a9
$teal: #83af9b

【问题讨论】:

  • 你能告诉我们与错误相关的样式表吗?

标签: css wordpress sass comments


【解决方案1】:

如果您尝试压缩 CSS,则需要添加感叹号 (!)。但是,如果您不想这样做,那么任何类型的评论风格都应该适合您。可接受的注释示例如下。有关 cmets 的更多信息,请访问 pagehere。这个question 也很有用。

/* This comment is
 * several lines long.
 * since it uses the CSS comment syntax,
 * it will appear in the CSS output. */

/*! This comment is
 * several lines long.
 * since it uses the CSS comment syntax,
 * it will appear in the CSS output. */

// Does not appear in output.

【讨论】:

  • 我正在压缩。尝试了上面评论中提到的感叹号。我还尝试将星号放在每一行。
  • 没关系,在你用感叹号格式化它时完全尝试过它并且它有效。
【解决方案2】:

你应该放一个 !在您希望保留的 cmets 之前:

/*!
Theme Name: Your Theme Name
*/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-31
    • 2019-04-18
    • 1970-01-01
    • 2011-11-25
    • 1970-01-01
    • 2015-09-22
    • 2020-03-30
    相关资源
    最近更新 更多