0

I have a problem - I am trying to include a background image using CSS for the layer, but it doesn't work... The CSS file looks like this

header {
background-image: url("boisko.jpg");
background-repeat: no-repeat;
background-size: 100%;
background-position: center;
}

The main file looks like this

<?php
error_reporting(0);
echo "<style>";
include "styl.css";
echo "</style>";
echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
<tr>
<td width=\"100%\" colspan=\"2\">";
include_once"Naglowek/index.php";
echo"<td>
</tr>
<td width=\"100%\" colspan=\"2\">";
include_once"Jezyk/index.php";
echo"</td>
</tr>
</table>";
?>

The background image should show in the cell where "Naglowek.index.php" is included, but it doesn't... That file looks like this:

<?php echo "<head><br><h1>Cracow Sunday Football League</h1><br><br></head>";?>

I know I could have written that file in html, but I would prefer it staying in php if it doesn't really matter.

Why doesn't my background image show up?

5
  • 3
    You should really rething what you are doing. There is no need to "echo out" html - just close the php tag and write html instead: <?php ... ?> here html <?php here php again ?> Commented Jun 23, 2016 at 12:57
  • 1
    please inspect html element .use browser console Commented Jun 23, 2016 at 12:57
  • When using images with CSS you need to use paths that are relative to the CSS file when not using absolute paths. Commented Jun 23, 2016 at 12:57
  • Are you getting PHP errors? Can you share those? Is the problem that the PHP file, Naglowek/index.php, isn't loading? Are you sure the file path is right? Why are you using echo over multiple lines? Each echo statement should be only one line long. Commented Jun 23, 2016 at 12:58
  • include "styl.css"; should probably be style.css but please rework that code Commented Jun 23, 2016 at 12:58

2 Answers 2

4

You have header in the CSS, but head in the HTML

Sign up to request clarification or add additional context in comments.

Comments

0

Well you kind of have the right idea. You can save your file as a .php and still write the HTML that is needed.

Change the pages to look like this.

Main Page:

`<?php 
 <html>
  <head>
   <!-- title for the document, scripts, styles, meta information,and more -->
  </head>
  <body>
     <table cellpadding="0" cellspacing="0" width="100%">
       <tr>
          <td width="100%" colspan="2">
            <?php include_once"Naglowek/index.php"?>
          <td>
      </tr>
          <td width="100%" colspan="2">
           <?php include_once"Jezyk/index.php"; ?>
          </td>
      </tr>
   </table>
   ?>`

As for the CSS I don't see anything class or ID called header so nothing is going to be applied.

<div class="header"></div>

As for the "Naglowek.index.php" file, it can stay the same as it being a .php file you just don't need the tags. Just straight HTML will work.

`<head><br><h1>Cracow Sunday Football League</h1><br><br></head>`

You should get rid of the head tags because they are a container for all the head elements.

I hope this helps clear things up

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.