gpt4 book ai didi

css - rails 上的 ruby : stylesheet in assets doesn't works

转载 作者:行者123 更新时间:2023-11-28 10:30:30 25 4
gpt4 key购买 nike

即使在阅读 http://guides.rubyonrails.org/asset_pipeline.html 之后,我的 Assets 管道也一直存在问题我仍然遇到麻烦。

当我在开发中加载我的页面时,我的 css 没有呈现,看起来 css 没有被考虑在内,因为如果我把这个 css 放入 <script></script>在我的页面 home.html.erb 的标题中,它工作得很好。

我在 app/assets/stylesheets/bootstrap.css.scss 中有这个样式表

bootstrap.css.scss

/* BOOSTRAP CSS */
/* /BOOSTRAP CSS */

.form-group {
width: 250px;
font-size: 10px;
opacity: 1;
}


.panel {
width:300px;
margin-left: auto;
margin-right: auto;
opacity: 0.8;
z-index: 10000;

}

.btn-default {
border: 1px solid #28c3ab;
color: #1abc9c;
background-color: #f1c40f;
}




.jumbotron {
background-color:#ecf0f1;
color:#1abc9c;
}

.btn-default {
color: #1abc9c;
background-color: #f1c40f;
}

.btn-default:hover,
.btn-default:focus {
border: 1px solid #28c3ab;
outline: 0;
color: #1abc9c;
background-color: #3498db;
}


.btn-primary {
border: 1px solid #28c3ab;
color: #f1c40f;
background-color: #1abc9c;
}

.btn-primary:hover,
.btn-default:focus {
border: 1px solid #28c3ab;
outline: 0;
color: #f1c40f;
background-color: #3498db;
}

这是我在 app/assets/stylesheets/application.css 中的 application.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
*= require 'masonry/transitions'
*= require_tree
*= require font-awesome
*= require bootstrap
*= require magnific-popup
*/

我不确定出了什么问题,我尝试预编译 Assets ,但仍然无法正常工作,我可能遗漏了什么?

我的布局中有指向我的样式表的链接,app/views/layouts/application.html.erb

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

最佳答案

当您为生产预编译您的 Assets 时,请确保您的开发环境没有也在使用这些 Assets 。因此,请检查您的 html 并确保您可以看到每个 css 文件而不仅仅是 application.css

如果您确实发现您正在使用预编译 Assets ,请运行 rake assets:clean,然后您的开发环境将使用正确的 css 文件。

关于css - rails 上的 ruby : stylesheet in assets doesn't works,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23550825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com