Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rails应用程序:css未按预期工作_Css_Ruby On Rails - Fatal编程技术网

Rails应用程序:css未按预期工作

Rails应用程序:css未按预期工作,css,ruby-on-rails,Css,Ruby On Rails,我尝试在一个基本的Rails应用程序中对html进行样式化。应用程序加载home.scss文件,但我的标题样式设置不起作用。似乎只有新字体系列有效。你知道这个问题吗 My application.html文件 <!DOCTYPE html> <html> <head> <title>Content Style</title> <%= csrf_meta_tags %> <%= stylesh

我尝试在一个基本的Rails应用程序中对html进行样式化。应用程序加载home.scss文件,但我的标题样式设置不起作用。似乎只有新字体系列有效。你知道这个问题吗

My application.html文件

<!DOCTYPE html>
<html>
  <head>
    <title>Content Style</title>
    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
  </head>

  <body>
    <header>
      <h1 id="logo">ContentStyle.co</h1>
      <% if notice %>
        <p class="alert alert-success"><%= notice %></p>
      <% end %>
      <% if alert %>
        <p class="alert alert-danger"><%= alert %></p>
      <% end %>
      <ul>
        <%= render 'devise/menu/registration_items' %>
        <%= render 'devise/menu/login_items' %>
      </ul>
    </header>
    <%= yield %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    <%= yield :save_js %>
  </body>
</html>
标题背景颜色应为蓝色,但以下是它的外观(h1文本如预期的那样为白色,因此我们看不到):

您是否尝试过任何故障排除措施,如检查控制台或rails日志?问题中的代码看起来非常好。我能看到的一件事是,你对flash消息的处理看起来有点不稳定和非常规-通常你只是在flash哈希中迭代。我应该在控制台中检查什么?这是一个看起来不错的日志:在2017-01-31 15:37:11+0100由HomeController处理开始GET“/”for::1#索引为HTML呈现home/index.HTML.erb在布局中/application呈现home/index.HTML.erb在布局中/application(0.6ms)呈现设备/菜单/_注册_items.HTML.erb(0.7ms)呈现的designe/menu/_login_items.html.erb(0.7ms)在39ms内完成了200 OK(视图:35.6ms | ActiveRecord:0.0ms)。奇怪的是,只有我的头{…}css没有被考虑在内……我只是更改了头{…}的位置,现在它可以工作了。。。神秘!可能类似于浏览器阻塞的不间断空格字符。
@import url('https://fonts.googleapis.com/css?family=Crete+Round');

body {
  font-family: 'Crete Round', serif;
}

header {
  width: 100%;
  height: 40px;
  padding: 20px 150px 20px 150px;
  background-color: #2C64C1;
}

#logo {
  color: white;
  font-size: 18px;
  font-weight: normal;
}