Rails 少 url 路径改变
Rails less url path change
使用 less-rails gem 开发 Rails 应用程序我发现了一些不寻常的东西:
// app/assets/common/css/desktop/typo.less
@font-face{
font-family:'SomeFont';
src:url("fonts/db92e416-da16-4ae2-a4c9-378dc24b7952.eot?#iefix");
// ...
}
要求的字体是
app/assets/common/css/fonts/db92e416-da16-4ae2-a4c9-378dc24b7952.eot
此字体用less编译,结果为:
@font-face {
font-family: 'SomeFont';
src: url("desktop/fonts/db92e416-da16-4ae2-a4c9-378dc24b7952.eot?#iefix");
//...
}
你知道为什么要在这里插入 desktop/
吗?它肯定与文件的路径有关,但我找不到任何东西。
编辑:我知道 image-url
、font-url
等内置方法,...但我需要保持这种组织方式并且只使用默认 url
方法。
(简单地说:我无法更改文件)
你应该使用font_url
,并将字体设置为app/assets/fonts
@font-face {
font-family: 'SomeFont';
src: font_url("db92e416-da16-4ae2-a4c9-378dc24b7952.eot?#iefix");
//...
}
使用 less-rails gem 开发 Rails 应用程序我发现了一些不寻常的东西:
// app/assets/common/css/desktop/typo.less
@font-face{
font-family:'SomeFont';
src:url("fonts/db92e416-da16-4ae2-a4c9-378dc24b7952.eot?#iefix");
// ...
}
要求的字体是
app/assets/common/css/fonts/db92e416-da16-4ae2-a4c9-378dc24b7952.eot
此字体用less编译,结果为:
@font-face {
font-family: 'SomeFont';
src: url("desktop/fonts/db92e416-da16-4ae2-a4c9-378dc24b7952.eot?#iefix");
//...
}
你知道为什么要在这里插入 desktop/
吗?它肯定与文件的路径有关,但我找不到任何东西。
编辑:我知道 image-url
、font-url
等内置方法,...但我需要保持这种组织方式并且只使用默认 url
方法。
(简单地说:我无法更改文件)
你应该使用font_url
,并将字体设置为app/assets/fonts
@font-face {
font-family: 'SomeFont';
src: font_url("db92e416-da16-4ae2-a4c9-378dc24b7952.eot?#iefix");
//...
}