2014-09-13 84 views
1

在我的布局上,我有3个pages.xhtml:顶部,正文和页脚。这些页面包含在<p:playout/> in template.xhtml 我想在页面Body.xhtml中添加背景图像,但图像不显示在所有区域。尝试添加背景图片?

如何在页面的所有区域显示图像?

在这里,我怎样,我想

的template.xhtml

<p:layout fullPage="true"> 
      <p:layoutUnit position="north"> 
       <ui:include src="/template/top.xhtml"/>     
      </p:layoutUnit> 

      <p:layoutUnit position="center"> 
       <ui:include src="/template/body.xhtml"/>     
      </p:layoutUnit> 

      <p:layoutUnit position="south"> 
       <ui:include src="/template/footer.xhtml"/> 
      </p:layoutUnit> 
     </p:layout> 

body.xhtml

<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:ui="http://java.sun.com/jsf/facelets" 
     xmlns:f="http://java.sun.com/jsf/core" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:p="http://primefaces.org/ui"> 
    <h:head> 
     <title>Facelet Title</title> 

     <style> 
      body{ 
       background-image: url("#{resource['imagens/background.png']}"); 
       width:100%; 
       height:100%; 
       background-repeat: no-repeat; 
       background-attachment:fixed;    
      } 
     </style> 

    </h:head> 
    <h:body> 

    eu sou o body (I'm body) 

    </h:body> 
</html> 

,结果

enter image description here

回答

3

body { background-image: url("#{resource['imagens/background.png']}"); background-size: cover; background-repeat: no-repeat; background-attachment:fixed;
}

+0

不错。但是这张图片像我张贴的图片那样开放。 – FernandoPaiva 2014-09-13 17:01:32

1

只是试图给这个:

<style> 
     body{ 
      background-image: url("#{resource['imagens/background.png']}");    
     } 
    </style>