html - Grails 从自定义 URL 加载 CSS

标签 html css grails

使用 Grails 2.4.4 版。并尝试从 URL 加载 CSS 资源

  1. http://myAppName.com:7777/myApp/assets/style.css

  2. /myApp/assets/style.css

我设置了 style.css :

@font-face {
  font-family: 'icomoon';
  src:  url('../fonts/icomoon.eot?t0751g');
  src:  url('../fonts/icomoon.eot?t0751g#iefix') format('embedded-opentype'),
  url('../fonts/icomoon.ttf?t0751g') format('truetype'),
  url('../fonts/icomoon.woff?t0751g') format('woff'),
  url('../fonts/icomoon.svg?t0751g#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}

除此之外,我还添加了一些其他选项来正确加载图标。

Assets 结构:

/assets/fonts/icomoon.ttf (所有其他 icomoon 文件都在这里)

/assets/stylesheets/style.css 

当我使用 2.url 时,它会正常加载我的自定义图标,但是当我在 <style> 中设置 1.url 时如上图,图标加载失败。

两个 url-s 应该指向同一个文件,我不明白为什么这不起作用。任何人都知道我做错了什么?

任何帮助将不胜感激!

最佳答案

所以我发现字体不支持跨域,我使用icomoon图标作为字体从另一个域导入它。另一方面,我发现您可以使用生成嵌入式 JS 并自动修复此问题的 Fontello,因此通常更好用。

关于html - Grails 从自定义 URL 加载 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48398259/

相关文章:

jquery - 通过 "inline"与一些未知的 css-overriding 问题作斗争

grails - Grails拆分应用程序

Grails 3.0.1 - 如何在 application.yml 中配置 grails.gorm.default.constraints

html - 如何在浏览器中设置默认打印选项

html - Doctype 搞乱了 CSS 字体样式?

javascript - 如何观看两个事件并在它们之后做些什么?

javascript - 我怎样才能将图像放入选择中?

grails - 如何通过Grails中的controller方法在URL中附加查询参数?

html - ems和像素有什么关系?

html - 如何更改可调整大小的文本区域的光标?