[英]CSS file location Ruby
It appears that in Ruby on Rails all CSS files are concatenated into one big file. 看起来在Ruby on Rails中,所有CSS文件都串联到一个大文件中。 If I define a p {}
in one CSS file the other pages follow suit. 如果我在一个CSS文件中定义p {}
,则其他页面也将随之而来。 I have tried the following: 我尝试了以下方法:
<link type="text/css" rel="posts" href="posts.css.scss" />
As well as: 以及:
<link type="text/css" rel="posts" href="assets/posts.css.scss" />
I can't seem to define one CSS file to one HTML page. 我似乎无法在一个HTML页面上定义一个CSS文件。 I have found an option which may work by disabling the asset pipeline as it explained to me but I think this may have adverse effects. 我已经找到了一个选项,它可以通过向我解释禁用资产管道来起作用,但是我认为这可能会产生不利影响。
How can I define one CSS file per HTML file? 如何为每个HTML文件定义一个CSS文件?
What you are looking for in a different CSS per page or action. 您在每页或每个操作中使用不同CSS查找的内容。 You can do this via: 您可以通过以下方式进行操作:
class UsersController < ApplicationController
layout 'some_custom_layout'
end
If you want to have for a particular action 如果您想采取特定的行动
def foo
# some logic here
render :layout => 'some_custom_layout'
end
eg: 例如:
#app/layouts/some_custom_layout.html.haml
!!!
%html{lang: "en"}
%head
%meta{charset: "utf-8"}/
%meta{content: "width=device-width, initial-scale=1.0", name: "viewport"}/
= stylesheet_link_tag "your_custom_css"
= javascript_include_tag "application"
= csrf_meta_tags
%body
= yield
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.