css - 如何在 CSS 中使用#resource?

标签 css eclipse jsf jsf-2 glassfish

这就是我在 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');
  }
}
*/

这是我的元素结构:

project

知道如何在这种情况下正确使用 #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/

相关文章:

eclipse - 在 Mac 中从 Eclipse 设置 tomcat

java - JSF: <f:convertDateTime 类型 ="date"模式 ="mm/DD/yyyy"/>

css - IE 8 Div 在附加较大的子项时消失

JavaScript/css 在 Sharepoint WebPart 中不起作用

html - z-index 类的内容

带有 jsf2.0、xhtml 和 primefaces 2.2.RC1 的 Eclipse 自动完成(内容辅助)

JSF 和组件树状态

html - flex 1 :1 is not working with Ionic grid. 我需要分配空间 50:50

python - 在 Eclipse 中为远程系统资源管理器启用 pep8

java - Maven 和 Java 的 ClassNotFoundException