Rails 4.1 Sass :: Pages#home中的SyntaxError

时间:2015-04-05 19:38:25

标签: javascript html css ruby-on-rails svg

尝试将背景图片添加到我的rails应用background: url('../img/dot-matrix.svg') 50% 0% repeat-y #fff;但是在“...”'dot-matrix“:expected”)“之后得到错误`无效的CSS”,是“.svg'%>' )50%......“

已复制assets / images目录下的dot-matrix.svg文件

转到我的css.scss文件并将其更改为background: url('<%= asset_path 'dot-matrix.svg' %>') 50% 0% repeat-y #fff;,以便在我的css.scss文件中显示该文件

.dotmatrix {
    background: url('<%= asset_path 'dot-matrix.svg' %>') 50% 0% repeat-y #fff;
    height: 100%;
    background-size: 50%;
    width: 10%;
    position: absolute;
}

但收到错误Invalid CSS after "...ath 'dot-matrix": expected ")", was ".svg' %>') 50% ..."

application.html.erb

<!DOCTYPE html>
<html>
<head>
  <title>Oc</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>
<body>


<%= yield %>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

我想你忘了逃避单引号。尝试使用此

background: url('<%= asset_path "dot-matrix.svg" %>') 50% 0% repeat-y #fff;