【问题标题】:Background image not including背景图片不包括
【发布时间】:2016-12-18 16:03:24
【问题描述】:

我尝试了很多方法来在我的 jsf 页面中包含背景图片,但都没有奏效。虽然我的页面可以识别我的样式表(因为它显示红色文本),但不包括图像。我应该在 pom.xml 中添加映射资源吗? 请指教。

This is my folder structure: 

`WebContent
 |-- META-INF
 |-- WEB-INF
 |-- resources
 |    |-- css
 |    |    |-- style.css
 |    |-- images
 |         |-- background.png
 |-- index.xhtml

这是我在 index.xhtml 中添加的:

<h:body class="main">
        <h:outputStylesheet library="css" name="index.css"></h:outputStylesheet>
        <p class="test"> some text </p>
</h:body>

这是我的 style.css:

.main { 
  background-image: url("#{resource['images:background.png']}");               
}
.test {
    color : red;
}

【问题讨论】:

标签: css image jsf background


【解决方案1】:

解决了!!

问题是我将class 属性而不是styleClass 放到body 标签中,这实际上是一个h:body 标签。谢谢大家的快速回答:)

【讨论】:

  • 我应该已经发现了这个错误,但是使用浏览器开发者工具你也应该这样做;-)。很好用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-11
  • 1970-01-01
  • 2020-09-11
相关资源
最近更新 更多