Add an image or icon to primefaces tab header

梦想与她 提交于 2019-12-30 05:46:06

问题


im trying to use an image /icon on a tab header instead of text title(or may using both of them), i was testing using titleStyleClass seting an image background but doesnt work

my primefaces tab:

 <p:tab titleStyleClass="tCliente" title="Vehiculo">

My css style

 .tCliente 

 {     
   background-image: url(../images/logo_tropidatos.gif);
 }

Thanks for your help :D


回答1:


On PrimeFaces 3.0 and newer you can add a facet to override title on tabs:

<p:tabView>
    <p:tab>
        <!-- overrides title on tab-->
        <f:facet name="title">
               <h:outputText value="tab title"/>
               <p:graphicImage value="/resources/images/icon.png"/>
            </f:facet>

        <h:panelGrid>
            <!-- tab content -->
        </h:panelGrid>
    </p:tab>    
</p:tabView>

Hope it helps.




回答2:


try adding display:inline-block;




回答3:


You should put:

background-image: url("../images/logo_tropidatos.gif") !important;

but after that i have a problem: the image repeat into the header. I tried to solve adding background-repeat:no-repeat; but is the same... can someone help?




回答4:


try this way

background-image: url("../images/logo_tropidatos.gif") !important;
background-repeat:no-repeat !important;


来源:https://stackoverflow.com/questions/8977591/add-an-image-or-icon-to-primefaces-tab-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!