I'm making a website Using JSF and richfaces, but I need to do some background images on the drop down menu labels. I saw you can use the style attribute by doing
.rich-ddmenu-label {
background-image: url("images/the_image.gif");
}
But that doesn't seem to even try and put a image anywhere.
I can use an image using
<h:graphicImage/>
I don't know how to put text on top of it though.
What am I doing wrong? How do I insert a background image behind some text?
I just had the same problem with JSF 2.0. I had to use a CSS and the solution with the relative path didn't work for me either (like Choghere posted).
In my book I read that when you use Facelets as VDL (View Declaration Language) it is possible to use expressions even in a plain HTML page. So I got the idea to put a EL directly in my CSS. Note: I didn't have to change the filename or anything.
Here is what I did. but first my filestructure:
Now here comes the CSS:
.someclass {
background-image:url("#{resource['images:logo.png']}");
}
in this case resource is an implicit object of JSF 2, images is the library where JSF should look (jsf expects all libraries/files under resources, at least the default ResourceHandler) and then the name of the resource.
For deeper structures it would be:
#{resource['images/folder:logo.png']}
Hope that helps ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With