我在 Grav CMS 中添加自定义字体时遇到问题。所有字体都添加到文件夹路径下:user/themes/bildxwerkstatt/fonts
当我在 .css 文件中添加此代码时,它可以在我的计算机上运行
@font-face {
font-family: MullerBlack;
src: url(/bildxwerkstatt/user/themes/bildxwerkstatt/fonts/Muller/MullerBlack.otf);}
h1, h2, h3, h4, h5, h6 {
font-family: MullerBlack, sans-serif!important;}
但是在主机上这样的路径不起作用。
正如我从 Grav 文档中了解到的,CSS 中字体的路径应该如下所示:
url(theme:fonts/Muller/MullerBlack.otf);}
但这对我来说不起作用。尝试在 css 中添加背景图像时遇到同样的问题。
提前致谢!
最佳答案
根据给定的信息,很难提供帮助。
bildxwerkstatt
是文档根目录下的一个文件夹也是主题名称吧?
首先要检查的是您是否拥有提供的 .htaccess
并设置了 RewriteBase
。参见 Grav Troubleshooting 404 Not Found
然后你应该检查你的 css 语法。
@import url('https://...
或使用 base.html.twiq
<link href="https://...
来自 Grav Asset Manager关于静态资源:
The url() method takes an optional second parameter of true or false to enable the URL to include the schema and domain.
同时检查可用的 Theme Variables .
The
{{ theme_url }}
returns the relative URL to the current theme.
这里是我如何为特定页面设置背景图片的示例:
{% set background_image = page.media.images|randomize|first %}
{% set background_image = background_image.name.cache.url %}
<div {% if background_image %} style="background-image: url({{ background_image }})"{% endif %}></div>
关于html - CSS 中的 Grav CMS 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54984900/