0

I'm trying to put an image/icon inside a button in Primefaces, problem is the image doesn't show. I'd used FireBug and look like the path is correct. Is there any problem or restrictions using Custom icons?

XHTML code:

<p:button type="button" value="Limpiar" icon="img-button-prismaticos" onclick="limpiar  ();return false;"  />

CSS Code:

.ui-state-default .img-button-prismaticos {
    background-image: url('/dinarep/faces/javax.faces.resource/prismaticos-icono-9281-48.png?ln=images') !important;
}

2 Answers 2

1

I fix the problem. It's related with the size of the span where imagen are located on the button. Is only 16x16!. I fix channging the size and margins of the span in CSS. I use important! to hack the CSS because i don't want to overwrite the default Primefaces Styles. And I want my margins has more priority.

.img-button-nube {
    background-image: url('/dinarep/faces/javax.faces.resource/nubes-icono.png?ln=images') !important;
    height: 28px;
    width: 28px;
    left: 0 !important;
    margin-left: 0 !important;
    top: 0 !important;
    margin-top: 0 !important;
}

and in the XHTML (no changes):

<p:button type="button" icon="img-button-nube" onclick="nubes();return false;"  />  

It's work for me...

Thanks

Sign up to request clarification or add additional context in comments.

Comments

0

try this without .ui-state-default

.img-button-prismaticos { background-image: url('/dinarep/faces/javax.faces.resource/prismaticos-icono-9281-48.png?ln=images') !important; }

best vj

1 Comment

I try with .ui-state-default and without this and don`t work...I fix the problem...I'll answer my cuestion with the solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.