【问题标题】:my whole rails app is getting css only from one file why我的整个 Rails 应用程序只从一个文件中获取 css 为什么
【发布时间】:2016-06-17 07:26:51
【问题描述】:

我为两个控制器添加了不同的 css 文件,但我的整个应用程序只从 product.css 获取 css

我为两个控制器添加了不同的 css 文件,但我的整个应用程序只从 product.css 获取 css 我为两个控制器添加了不同的 css 文件,但我的整个应用程序只从 product.css 获取 css

products.css

body {
    font-size: 11px;
    font-family: 'Open Sans', sans-serif;
    color: #4A4A4A ;
    text-align: center;
}

.wrap {
    background: #fff;
    margin: 20px auto;
    display: block;
    width: 300px;
    height: 380px;
    padding:20px;
    border-radius: 2px 2px 2px 2px; 
    -webkit-box-shadow: 0 1px 4px 
    rgba(0, 0, 0, 0.3), 0 0 40px 
    rgba(0, 0, 0, 0.1) inset;
    -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
    box-shadow: 0 1px 4px 
    rgba(0, 0, 0, 0.3), 0 0 40px 
    rgba(0, 0, 0, 0.1) inset;
    float: left;
    margin-right: 29px;
}

.wrap img {
    width: 100%;
    margin-top: 15px;
}

p{ 
    margin-top: 15px;
    text-align: justify;
}

h1{
    font-size: 20px;
    font-weight: bold;
    margin-top: 5px; 
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

a{
    text-decoration: none;
    color: #4A4A4A !important;
}

a:hover{
    text-decoration: underline;
    color: #6B6B6B !important ;
}

**

【问题讨论】:

  • 请不要重复同一个问题。而是编辑您的问题,添加更多详细信息 - 它将在列表中向上移动。请在此问题中显示您的其他 css 文件以及您的 application.css 文件。你怎么知道 products.css 是唯一被使用的文件?

标签: ruby-on-rails css sass


【解决方案1】:

好的,您正在使用与 CSS 混合的 SCSS,我的建议是将 product.css 更改为 product.scss 并使用

导入路径
 @import '/*';
 @import '/**/*'; 

根据您的文件夹结构,如果 rails 无法找到任何文件,它会抛出错误,因为 rails 没有拾取 scss 文件。

您还可以删除所有资产管道内容并执行@import 'font-awesome';

【讨论】:

  • 您的文件夹结构是什么样的?以及文件扩展名。
  • 你能解释一下文件夹结构是什么意思吗@Chong Hui
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 2021-12-31
  • 1970-01-01
  • 2014-09-03
  • 1970-01-01
  • 1970-01-01
  • 2015-12-08
相关资源
最近更新 更多