Materialize CSS / Rails:Roboto字体未加载,未应用所有CSS

3
使用Ruby on Rails和Materialize CSS时,Roboto字体无法呈现。此外,按钮文本未被正确地样式化,因此它不是粗体,并且如果我点击按钮,则为灰色。

A screenshot of a front page of a website. It is styled with Materialize CSS. The Roboto font is not being rendered correctly. It is replaced with another font.

我的布局:

application.html.erb

<!DOCTYPE html>
<html>
<head>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

  <title><%= yield(:title) %></title>

  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
</head>
<body>

<%= yield %>

</body>
</html>

我无法弄清楚这个问题。有人可以帮帮我吗?

我尝试过以下方法:

  • 使用materialize-sass gem
  • 手动加载字体
  • 在我的电脑上安装字体

你在哪里设置字体? 你需要创建一个字体集,然后将其包含在CSS选择器中。 - siegy22
@siegy Materialize自动设置字体... - anna328p
@ siegy 它也应该使按钮文本变为白色,但显然没有发生。 - anna328p
你打开了检查器吗?有错误吗? - siegy22
@siegy 我打开了检查器,但似乎没有一个。 - anna328p
1个回答

0

解决方案

scaffolds.css.scss 中预定义了一些 CSS 规则,将字体设置为 Verdana。删除它们可以解决问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接