【问题标题】:Setting the background image for p:panel为 p:panel 设置背景图像
【发布时间】:2013-04-23 14:06:15
【问题描述】:

我正在尝试使用以下代码显示带有背景图像的面板。

    <p:panel id="upperpanel" style="background-image: url(../img/login-bg.jpg)" >

我也尝试过使用

  <p:panel id="upperpanel" style="background-image: url(/user/test/img/login-bg.jpg)" >

在这两种情况下,我都没有显示背景图像。我也尝试使用不同的图像。没有运气。当我在面板中添加 h:graphicImage 组件时,图像会正确显示。

任何帮助将不胜感激。

【问题讨论】:

    标签: css jsf primefaces panel


    【解决方案1】:
    style="background-image: url('../img/login-bg.jpg');
    

    会工作的。在 style 属性中添加 !important 也是不必要的,因为您在 style 中定义的任何 css 规则已经覆盖了其他具有相同名称的 css 属性。 !important.css 文件中使用时会很有用。

    【讨论】:

    • 我尝试了上述步骤...由于某种原因,它仍然不适合我...可能有任何浏览器兼容性问题吗? .. 不幸的是,我使用的是 IE8... 必须在 Firefox 中进行测试
    • @RealChembil 可以。有很多关于 IE8 和背景图片的建议。但请确保您提供了正确的网址,您可以通过提供background-image: url('http://www.google.com.tr/logos/2013/national_sovereignty_and_childrens_day_2013-1379007-hp.jpg'); 对其进行测试。并确保使用 '' 作为样式属性,使用 "" 作为 css 类。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-05
    • 2015-01-24
    • 2015-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多