【发布时间】:2015-01-26 10:25:36
【问题描述】:
如何在 bootstrap sass 版本中设置相对 glyphicons 图标路径?
默认情况下,css font-face 中使用的路径是绝对路径。
@font-face {
font-family: 'Glyphicons Halflings';
src: url(/fonts/bootstrap/glyphicons-halflings-regular.eot?1422262129);
src: url(/fonts/bootstrap/glyphicons-halflings-regular.eot?&1422262129#iefix) format("embedded-opentype"), url(/fonts/bootstrap/glyphicons-halflings-regular.woff2?1422262129) format("woff2"), url(/fonts/bootstrap/glyphicons-halflings-regular.woff?1422262129) format("woff"), url(/fonts/bootstrap/glyphicons-halflings-regular.ttf?1422262129) format("truetype"), url(/fonts/bootstrap/glyphicons-halflings-regular.svg?1422262129#glyphicons_halflingsregular) format("svg");
}
但我需要一个相对的:“../fonts/bootstrap” - 所以在文件 _bootstrap-variables.scss 中,我设置了 $icon-font-path
$icon-font-path: "../fonts/bootstrap/"
给出以下内容
@font-face {
font-family: 'Glyphicons Halflings';
src: url(/fonts/../fonts/bootstrap/glyphicons-halflings-regular.eot?1422262129);
src: url(/fonts/../fonts/bootstrap/glyphicons-halflings-regular.eot?&1422262129#iefix) format("embedded-opentype"), url(/fonts/../fonts/bootstrap/glyphicons-halflings-regular.woff2?1422262129) format("woff2"), url(/fonts/../fonts/bootstrap/glyphicons-halflings-regular.woff?1422262129) format("woff"), url(/fonts/../fonts/bootstrap/glyphicons-halflings-regular.ttf?1422262129) format("truetype"), url(/fonts/../fonts/bootstrap/glyphicons-halflings-regular.svg?1422262129#glyphicons_halflingsregular) format("svg");
}
在网上我找到了在变量之前包含“bootstrap-sprockets”的提示,结果是
@font-face {
font-family: 'Glyphicons Halflings';
src: url(font-path("../fonts/bootstrap/glyphicons-halflings-regular.eot"));
src: url(font-path("../fonts/bootstrap/glyphicons-halflings-regular.eot?#iefix")) format("embedded-opentype"), url(font-path("../fonts/bootstrap/glyphicons-halflings-regular.woff2")) format("woff2"), url(font-path("../fonts/bootstrap/glyphicons-halflings-regular.woff")) format("woff"), url(font-path("../fonts/bootstrap/glyphicons-halflings-regular.ttf")) format("truetype"), url(font-path("../fonts/bootstrap/glyphicons-halflings-regular.svg#glyphicons_halflingsregular")) format("svg");
}
网址本身似乎没问题 - 但是这个“字体路径”来自哪里,我该如何摆脱它?
或者还有其他方法可以指定相对路径吗?我哪里错了?
【问题讨论】:
-
你解决过这个问题吗?
标签: twitter-bootstrap bootstrap-sass