2017-01-23 94 views
0
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <link rel="stylesheet" type="text/css" href="css/font-awesome.css"> 

     <style type="text/css"> 
      body { 
       background-image: url(man_meteor.jpg); 
       background-repeat: no-repeat; 
       background-size: cover; 
       background-attachment: fixed; 
       background-position: center; 
      } 

爲什麼我的背景img不顯示? 以下是我的文件如何排列。 enter image description hereCSS background-image not showing

+0

NB:CONTENT = 「text/html的;字符集= UTF-8」 改變內容= 「text/html的」 字符集= UTF-8「 –

+1

等一下,你調用它的html文件在哪裏? –

+0

對我來說工作正常 –

回答

1

當您建議您的內容寫入名爲home.jsp的文件內時,我懷疑您是將「/」映射到將您的home.jsp轉發給客戶端的servlet之一。這是不對的,因爲這個映射會將每個其他資源映射到您用來轉發您的home.jsp的同一個servlet。正確的映射是用「」來代替。

一個在web.xml的塊應該是這樣的,而不是:

<servlet-mapping> 
    <servlet-name>The name of your servlet that forwards home.jsp</servlet-name> 
    <url-pattern></url-pattern> 
</servlet-mapping> 
+0

OMG!你是一個天才! –

0

看到你的代碼,我可以說,你需要指定height:200px OR height:400px例子,接下來的只是安全添加雙引號像background-image: url("man_meteor.jpg");。嘗試這些,其他方式來解決。