Rails stylesheet_link_tag 的问题。。。背景图片不显示

macknight · 2015年02月16日 · 最后由 imconfused 回复于 2015年03月06日 · 2051 次阅读

<%= stylesheet_link_tag "application", :media => "all" %>

我在 layout 中把这句话去掉,然后背景图片就不显示了。。。 我主要不想加载那些多余的 css...

我后来在 stylesheets 文件夹里建了个 xxx.css,里面是: /*

  • This is a manifest file that'll be compiled into application.css, which will include all the files
  • listed below. *
  • Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
  • or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. *
  • You're free to add application-wide styles to this file and they'll appear at the top of the
  • compiled file, but it's generally better to create a new file per style scope. * *= require_self */

然后在 layout 文件中这样用: <%= stylesheet_link_tag "xxx", :media => "all" %>

多余的 css 没了,但是我的 div 的 background-image 也没了。。。 求大神解答

使用 scss,并且:

background-image: image-url('图片地址')

div 的 background-image 定义在哪个 css/scss 文件 你自己定义的 xxx.css 就要包含这个文件才行

需要 登录 后方可回复, 如果你还没有账号请 注册新账号