简体   繁体   English

Ruby on Rails样式表

[英]Ruby on Rails Stylesheet

I am trying to connect my website to a style sheet in Ruby on Rails but I don't know how to . 我正在尝试将我的网站连接到Ruby on Rails中的样式表,但我不知道该如何做。 I have a stylesheet in my application.html.erb file but I don't know how to get to it or what the name of it is . 我的application.html.erb文件中有一个样式表,但是我不知道如何获取它或它的名字。 I do have a pages.scss but when I put in css it doesn't show the changes on my website . 我确实有一个pages.scss,但是当我放入CSS时,它没有显示我网站上的更改。 Can someone help ? 有人可以帮忙吗?

application.html.erb: application.html.erb:

<!DOCTYPE html>
<html>
<head>
<title>AucIt</title>
<%= stylesheet_link_tag    'default', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'default', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>

home.html.erb : home.html.erb:

<!DOCTYPE html>
<html>
<body bgcolor="#E6E6FA">    
<h1>AucIt</h1>

 <nav>  

  <ul>
   <li style="font-size: 20px"><a href="#">Sign Up</a></li>
   <li style="font-size:20px"><a href="#">Login</a></li>
   <li style="font-size:20px"><a href="#">List</a></li>

</ul>

</nav>

</body>
</html>

First of all, check whether you have added pages.scss in default.css ? 首先,检查是否在default.css中添加了pages.scss?

 *= require pages 

If you are running your server in production mode, don't forget to run command 如果您在生产模式下运行服务器,请不要忘记运行命令

RAILS_ENV=production rake assets:precompile

Given that you say you don't know where that file is, I think you've mistakenly put default instead of application for the name of your css file. 考虑到您说您不知道该文件在哪里,我认为您错误地将default而不是application用作css文件的名称。 Otherwise you would know where it is because you created it. 否则您会知道它在哪里,因为您创建了它。

change this 改变这个

<%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true %>

to this 对此

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

And then so long as you have a pages.scss at app/assets/stylesheets/pages.scss make sure you add the following in your application.css file (which is located at app/assets/stylesheets/application.css ) 然后,只要在app/assets/stylesheets/pages.scss pages.scss处有一个pages.scss,请确保将以下内容添加到application.css文件(位于app/assets/stylesheets/application.css

*= require "pages"
*= require_self
*/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM