twitter-bootstrap – Bootstrap – Sass:相对的glyphicons图标
发布时间:2020-12-17 21:21:20 所属栏目:安全 来源:网络整理
导读:如何在bootstrap sass版本中设置相对glyphicons图标路径? 默认情况下,css font-face中使用的路径是绝对路径. @font-face { font-family: 'Glyphicons Halflings'; src: url(/fonts/bootstrap/glyphicons-halflings-regular.eot?1422262129); src: url(/font
如何在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"); } 网址本身似乎没问题 – 但这个“字体路径”来自何处,我该如何摆脱它呢? 或者是否有另一种指定相对路径的方法?我错了什么? 解决方法
在不使用罗盘的情况下解决此问题的一种简单方法是在包含引导程序之前声明字体路径功能.你的sass应该如下:
app.scss // your bootstrap default overrides here $icon-font-path: '../fonts/bootstrap/'; @function font-path($path) { @return $path; } @import 'bootstrap-sprockets'; @import 'bootstrap'; // your application styles here 有点黑客,我不确定是否还有其他任何东西不能用这样的设置(不使用指南针),但它似乎对我来说是有用的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |