2017-06-15 64 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,非常兴奋!谢谢主!我祈祷了,解决了!

其实,它很容易,只是因为照片被保护,我让它们可读。就这样!