Add an image or icon to primefaces tab header

2020-03-01 05:37发布

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

4条回答
闹够了就滚
2楼-- · 2020-03-01 06:10

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?

查看更多
萌系小妹纸
3楼-- · 2020-03-01 06:12

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.

查看更多
三岁会撩人
4楼-- · 2020-03-01 06:28

try adding display:inline-block;

查看更多
做个烂人
5楼-- · 2020-03-01 06:30

try this way

background-image: url("../images/logo_tropidatos.gif") !important;
background-repeat:no-repeat !important;
查看更多
登录 后发表回答