css - 如何在 primefaces 中创建自定义图标

标签 css jsf primefaces

我想创建一个新图标以在我的 p:commandButton 中使用,但我失败了,我使用了这个方法

PrimeFaces: how can I make use of customized icons?

但对我没有用。我会告诉你我的代码:

CSS 代码:

.img-button-help { background-image: url('img/mag.ico') !important; }

jsf代码:

<p:commandButton icon="img-button-help" value="test" />

结果: enter image description here新结果 -> enter image description here

如何在 Primefaces 中使用自定义图标??

最佳答案

您好,您可以尝试将 background-position 添加到您的 css,因为 primefaces 图像是基于 Sprite 的,而 .img-button-help 所做的是设置一个位置.试试这个:

.img-button-help { 
   background-image: url('img/mag.ico') !important;  
   background-position: center !important;
}

关于css - 如何在 primefaces 中创建自定义图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19594068/

相关文章:

html - CSS Image Sprites 在 IE7 中不工作

javascript - 单击 JSF 表时打开一个新页面

jsf - 阻止 p :commandButton displayed on a p:confirmDialog in addition to displaying a dynamic message on the dialog

html - 为什么我的表格单元格与其包含的文本高度不同?

css - 如何使用 Bootstrap 声明列表?

css - 可见性:hidden and display:none?有什么区别

tomcat - MyFaces 1.2.8 导致 Tomcat 6 在部署时崩溃

java - 将 OpenSessionInViewInterceptor 与 Hibernate 和 JSF 2 结合使用

jsf-2 - 数据表更新后,Primefaces 数据表在过滤器字段中丢失文本

java - 无法通过 primefaces 命令按钮调用方法