1 reply [Last post]
Jumentao
Jumentao's picture
Offline
newbie
Last seen: 6 years 7 weeks ago
Timezone: GMT-3
Joined: 2015-06-10
Posts: 1
Points: 2

Hi guys,

I'm having trouble with my background not working. I'va made a wrapper/container to set my background in it, because I have different backgrounds for each page on the site. If I just put "background: black;" instead of the image that I want as background it works, which is strange since the url to the image is correct.

Here is the code:

Home.php

<?php include("incl/config.php");
$title = "Hem";
$pageId = "hem";
$pageStyle = null;
?>
 
<?php include("incl/header.php"); ?>
 
<div id="containerhome">
 
<div id="start">
<h1>Welcome</h1>
 
</div>
 
<div id="arrow">
<a href="#arrowtop">
<img src="img/chevronb.png" alt="chevron">
</a>
</div>
 
<div id="prev">
 
<h3>Article</h3>
 
</div>
</div>
<?php include("incl/byline.php"); ?>
<?php include("incl/footer.php"); ?>

from the stylesheet:

#containerhome {
        background: url("img/church.jpg") no-repeat center center fixed;
        background-size:cover;
}

Anybody has any idea what may be the error?

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 21 weeks 3 days ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

Too little info to do more than guess

Do you have that available on a public facing server? That is, can you give us a link to the page?

Else, please post the actual html --- not the php --- and the full css. Then we can make a somewhat better guess. The site structure may be the critical issue, and without seeing it as served, :shrug:

Now, for my SWAG, where is the stylesheet located? Remember, the relative address of the bg image is relative to the stylesheet.

If the image is at /img/church.jpg, and the stylesheet is at /css/mystyles.css, then you have and address error since your style rule expects the image to be at /mystyles/img/church.jpg. This is a very, very common author bug, as we tend to forget that /css has a different starting point from /.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.