这就是我在 index.xhtml
中引用我的 css
文件的方式:
<h:outputStylesheet library="css" name="vendors/fontello.css" />
这就是我使用 #resources
的方式,效果很好:
background-image: url("#{resource['img:lang/ico-en.gif']}");
这是它在 HTML 元素中的工作方式:
@font-face {
font-family: 'fontello';
src: url('../font/fontello69db.eot?24671060');
src: url('../font/fontello69db.eot?24671060#iefix') format('embedded-opentype'),
url('../font/fontello69db.woff?24671060') format('woff'),
url('../font/fontello69db.ttf?24671060') format('truetype'),
url('../font/fontello69db.svg?24671060#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'fontello';
src: url('../font/fontello.svg?24671060#fontello') format('svg');
}
}
*/
然后,当我将 HTML 元素移动到 JSF 2 元素时,我想使用 #resources
,对吗?所以我做了和以前一样的事情,但没有用:
@font-face {
font-family: 'fontello';
src: url("#{resource[css:font/fontello69db.eot?24671060']}");
/* src: url("#{resource[css:font/fontello69db.eot?24671060');*/
src: url("#{resource[css:font/fontello69db.eot?24671060#iefix']}") format('embedded-opentype'),
url("#{resource[css:font/fontello69db.woff?24671060']}") format('woff'),
url("#{resource[css:font/fontello69db.ttf?24671060']}") format('truetype'),
url("#{resource[css:font/fontello69db.svg?24671060#fontello']}") format('svg');
font-weight: normal;
font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'fontello';
src: url("#{resource[css:font/fontello.svg?24671060#fontello']}") format('svg');
}
}
*/
这是我的元素结构:
知道如何在这种情况下正确使用 #resource
吗?
最佳答案
从字体文件名中删除 url 参数。试试看。
@font-face {
font-family: 'fontello';
src: url("#{resource[css:font/fontello69db.eot']}?24671060");
src: url("#{resource[css:font/fontello69db.eot']}?24671060#iefix") format('embedded-opentype'),
url("#{resource[css:font/fontello69db.woff']}?24671060") format('woff'),
url("#{resource[css:font/fontello69db.ttf']}?24671060") format('truetype'),
url("#{resource[css:font/fontello69db.svg']}?24671060#fontello") format('svg');
font-weight: normal;
font-style: normal;
}
关于css - 如何在 CSS 中使用#resource?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23970705/