2014-09-13 89 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>