application.css.scss没有工作,但其他人工作

时间:2015-03-14 10:29:58

标签: ruby-on-rails

Rails loads all stylesheets except application.css.scss有同样的问题,我提出了这个问题,因为没有给出解决方案。

如标题中所述,所有其他css文件都有效,而application.css.scss几乎没有效果。当我说"几乎"这意味着删除application.css.scss后会有一些差异我很抱歉我没有足够的声誉来发布图片。

请帮帮我......

application.html.erb

<!-- START:head -->
<!DOCTYPE html>
<html>
<head>
  <title>Pragprog Books Online Store</title>
  <%= stylesheet_link_tag    "application", media: "all",
    "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
  <%= csrf_meta_tags %>
</head>
<!-- END:head -->
<body class="<%= controller.controller_name %>">
  <div id="banner">
    <%= image_tag("logo.png") %>
    <%= @page_title || "Pragmatic Bookshelf" %>
  </div>
  <div id="columns">
    <div id="side">
<!-- START_HIGHLIGHT -->
      <div id="cart">
        <%= render @cart %>
      </div>

<!-- END_HIGHLIGHT -->
      <ul>
        <li><a href="http://www....">Home</a></li>
        <li><a href="http://www..../faq">Questions</a></li>
        <li><a href="http://www..../news">News</a></li>
        <li><a href="http://www..../contact">Contact</a></li>
      </ul>
    </div>
    <div id="main">
      <%= yield %>
    </div>
  </div>
</body>
</html>

application.css.scss

/*
* 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
*= require_tree .
*/

/* START_HIGHLIGHT */
#banner {
  background: #9c9;
  padding: 10px;
  border-bottom: 2px solid;
  font: small-caps 40px/40px "Times New Roman", serif;
  color: #282;
  text-align: center;

  img {
    float: left;
  }
}

#notice {
  color: #000 !important;
  border: 2px solid red;
  padding: 1em;
  margin-bottom: 2em;
  background-color: #f0f0f0;
  font: bold smaller sans-serif;
}

#columns {
  background: #141;

  #main {
    margin-left: 17em;
    padding: 1em;
    background: white;
  }

  #side {
    float: left;
    padding: 1em 2em;
    width: 13em;
    background: #141;

    form, div {
      display: inline;
    }

    input {
      font-size: small;
    }

    #cart {
      font-size: smaller;
      color: white;

      table {
        border-top: 1px dotted #595;
        border-bottom: 1px dotted #505;
        margin-bottom: 10px;
      }
    }

    ul {
      padding: 0;
      li {
        list-style: none;
        a {
          color: #bfb;
          font-size: small;
        }
      }
    }
  }
  #time {
    background: red;
    color: red;
  }
}

.depot_form {
  fieldset {
    background: #efe;
      legend {
        color: #dfd;
        background: #141;
        font-family: sans-serif;
        padding: 0.2em 1em;
      }
    }
    form {
      label {
        width: 5em;
        float: left;
        text-align: right;
        padding-top: 0.2em;
        margin-right: 0.1em;
        display: block;
      }
      select, textarea, input {
        margin-left: 0.5em;
      }
      .submit {
        margin-left: 4em;
      }
      br {
        display: none
      }
    }
  }

2 个答案:

答案 0 :(得分:0)

您可以查看不同的想法:

  1. application.css.scss 中,您必须包含:

    *= require_self

    *= require_tree

  2. 检查您是否还没有application.css文件

  3. 环境/ production.rb 上,你必须拥有:

    config.assets.enabled = true

  4. 或者类似的东西可以帮助你 application.rb

    config.assets.paths << "#{Rails.root}/app/assets"

答案 1 :(得分:0)

而是使用'#'使用'。' (比如.banner)并使用

<div class = "banner"> 

而不是

<div id = "banner">