如何在使用richfaces和CSS的JSF应用程序中添加背景图像? [英] How do I add background images in a JSF application using richfaces and CSS?

查看:172
本文介绍了如何在使用richfaces和CSS的JSF应用程序中添加背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个网站使用JSF和richfaces,但我需要在下拉菜单标签上做一些背景图片。我看到你可以使用style属性通过执行

  .rich-ddmenu-label {

background -image:url(images / the_image.gif);

}

但这似乎甚至没有尝试,



我可以使用

使用图片

 < h:graphicImage /> 

我不知道如何把文本放在上面。



我做错了什么?如何在一些文本后插入背景图片?

解决方案

假设有问题的元素获得 class =rich-ddmenu-label应用于它,问题很可能是背景图片的路径。



路径是相对的到CSS所在的位置。如果它在一个外部文件中,它应该是相对的,例如:

  /css/styles.css 
/images/the_image.gif

CSS应为:

  background-image:url(../ images / the_image.gif); 

如果CSS在HTML页面上是内联的,它将相对于当前路径。因此,如果页面位于 http:// server / path / to / page ,它将在 http:// server /path/to/page/images/the_image.gif ,当你可能意味着 http://server/images/the_image.gif 。 / p>

如果没有回答,请张贴生成的HTML。


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?

解决方案

Assuming the element in question is getting a class="rich-ddmenu-label" applied to it, the problem is likely the path to the background image.

The path is relative to where the CSS is located. If it's in an external file, it should be relative to that, e.g.:

/css/styles.css
/images/the_image.gif

the CSS should be:

background-image: url("../images/the_image.gif");

If the CSS is inline on the HTML page, it will be relative to the current path. So if the page is located at http://server/path/to/page, it will look for the image at http://server/path/to/page/images/the_image.gif, when you probably meant http://server/images/the_image.gif.

If that doesn't answer it, please post the generated HTML.

这篇关于如何在使用richfaces和CSS的JSF应用程序中添加背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆