2017-06-15 40 views
0

我正在構建一個使用PHP的網站。首先我完成了全部html,css,js,如圖所示。將HTML轉換爲PHP後,CSS背景圖像失敗

然後我開始將html轉換爲php

但是,在將html轉換爲php後,css中的背景圖像失敗。 我檢查了路徑,它在html中有效。

my files

我不知道什麼是錯的代碼。

當我將html轉換爲PHP時,需要對CSS做任何特殊操作嗎?

body { 
    background: url('../img/bg3.jpg') center; 
    position: relative; 
    height:1300px; 
} 

#wrapper{ height:1500px;} 

#wrapper{overflow: hidden;} 
.wrapper-head { 
    background: black url('../img/head.jpg') center no-repeat; 
    margin: 0 auto; 
    width: 908px; 
    height: 178px; 
    margin-top: 39px; 
    margin-bottom: 0px; 
    box-shadow: -2px 0 20px 1px #7f7e7f, 0 -2px 20px 1px #7f7e7f, 2px 0 20px 1px #7f7e7f; 
    border-bottom: solid 1px #ff0000; 
    position: relative; 
} 

.wrapper-head img { 
    float: right; 
    position: relative; 
} 

.wrapper-nav { 
    background: url('../img/nav.jpg') center no-repeat; 
    width: 1009px; 
    height: 83px; 
    margin: 0 auto; 
    margin-top: 0px; 
    -ms-transform: translate(0px, -33px); 
    /* IE 9 */ 
    -webkit-transform: translate(0px, -33px); 
    /* Safari */ 
    transform: translate(0px, -33px); 
    /* Standard syntax */ 
    margin-bottom: 0px;[![enter image description here][2]][2] 
    color: #281d04; 
} 

的整個路徑是:

/Applications/XAMPP/xamppfiles/htdocs/myblog/petshop/public 

什麼特別的是,當我打開這個路徑:

http://localhost/petshop/public/img/bg3.jpg 

它說:使用

Access forbidden! 

You don't have permission to access the requested object. It is either read-protected or not readable by the server. 

If you think this is a server error, please contact the webmaster. 

Error 403 

localhost 
Apache/2.4.23 (Unix) OpenSSL/1.0.2h PHP/7.0.9 mod_perl/2.0.8-dev Perl/v5.16.3 

其他照片只能在同一個文件夾中的html中工作在CSS中的三個失敗。

+5

你能發表相關的代碼嗎? –

+0

你是什麼意思將HTML轉換爲PHP? HTML可以放在標籤之外的PHP文件中。 – ottiem

+0

搜索並替換您的所有文件「index.html to index.php」。在PHP中更改HTML文件時沒有什麼可做的。 我想你的CSS有一個錯誤的路徑。你能提供你的整個代碼嗎? –

回答

0

最後我解決了這個問題!它花了我一個晚上!這是我第一次把html改成php,非常興奮!謝謝主!我祈禱了,解決了!

其實,它很容易,只是因爲照片被保護,我讓它們可讀。就這樣!