Displaying a background image on webpage behind existing content with CSS

scubbastevie

Hi I have a system developed with PHP and CSS.

I wish to have background images that will cover the full screen of each page. However with my existing setup the image covers the other content on screen. I have tried this with my homepage initially. I created an img tag (Learning) in my php file on line 19 as shown.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['username']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
 <div id="left">
    <label>NHSCT E-Learning Portal</label>
    </div>
    <div id="right">
     <div id="content">
         Welcome <?php echo $userRow['forename']; ?>&nbsp;<a href="logout.php?logout">Sign Out</a>
        </div>
    </div>
</div>
<img src="images/Learning.jpg" id= "Learning" alt="">
<br>
<p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg">
<br>
<center>
<h1> Select an E-Learning Module<h1>
<br>
<table align="center" height="200" width="40%" border="0">
<tr>
<td><button name="Surface" onclick="window.location.href='SurfaceExecute.php'">Surface Pro Basic Skills</button></td>
</tr>
<td><button name="eNISAT" onclick="window.location.href='eNISATExecute.php'">eNISAT Tutorials</button></td>
</tr>
<td><button name="Email" onclick="window.location.href='EmailExecute.php'">Email Tutorials</button></td>
</tr>
<td><button name="Policies" onclick="window.location.href='Policyview.php'">Policies and Procedures</button></td>
</tr>
</table>
</body>
</html>

I then added the following CSS to my style.css file

/* css for home page  */
#Learning {
  position: fixed; 
  top: -20; 
  left: 0; 

  /* Preserve aspet ratio */
  min-width: 100%;
  min-height: 100%;
}

My question is, how do I display this image in the background with existing screen content on top? Or is there a way to make the background image opaque so that the other content can be seen through it and clicked?

UPDATE Solution found from the answer provided. Removed img tag from php file and updated CSS to the following

html { 
  background: url(images/Learning.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
Guillaume Giraudon

You would use the background-image property in CSS. If you are doing that for the whole page, you might as well use it on the body element :

body {
   background-image : ........;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

video background is displaying over content on webpage

From Dev

CSS/PHP - Background image moving behind content and going off the screen

From Dev

CSS Background Image not displaying on mobile

From Dev

background image not displaying css/html

From Dev

CSS: div with background image not displaying

From Dev

Why is CSS content image not displaying?

From Dev

Local CSS background-image not displaying

From Dev

Displaying an image as a background of a html form using CSS

From Dev

CSS blur on background image but not on content

From Dev

webpage not displaying my css

From Dev

Parallax Background revealing the edge of the image and content going behind it

From Dev

image sprites as background on webpage

From Dev

How to add a repeating png image in the background of a webpage using CSS?

From Dev

CSS: centered content, left aligned background image

From Dev

CSS adjust brightness of image background and not content

From Dev

CSS background image exxpand as by content in html

From Dev

Translucent nav bar with background image behind: css, no javascript

From Dev

visualforce background image not displaying

From Dev

Body background image not displaying

From Dev

background image not displaying correctly

From Dev

Body background image not displaying

From Dev

Background Image is not displaying in Div

From Dev

Background Image not Displaying in Chrome

From Dev

CSS - displaying a dynamic height floated DIV - missing background image

From Dev

background-image in HTML, CSS and JavaScript game not displaying

From Dev

Firefox Add-On CSS not displaying background-image

From Dev

CSS Background Image Not Displaying ( using HTML5 Boilerplate)

From Dev

CSS: content not displaying

From Dev

drop down menu displaying behind content

Related Related

  1. 1

    video background is displaying over content on webpage

  2. 2

    CSS/PHP - Background image moving behind content and going off the screen

  3. 3

    CSS Background Image not displaying on mobile

  4. 4

    background image not displaying css/html

  5. 5

    CSS: div with background image not displaying

  6. 6

    Why is CSS content image not displaying?

  7. 7

    Local CSS background-image not displaying

  8. 8

    Displaying an image as a background of a html form using CSS

  9. 9

    CSS blur on background image but not on content

  10. 10

    webpage not displaying my css

  11. 11

    Parallax Background revealing the edge of the image and content going behind it

  12. 12

    image sprites as background on webpage

  13. 13

    How to add a repeating png image in the background of a webpage using CSS?

  14. 14

    CSS: centered content, left aligned background image

  15. 15

    CSS adjust brightness of image background and not content

  16. 16

    CSS background image exxpand as by content in html

  17. 17

    Translucent nav bar with background image behind: css, no javascript

  18. 18

    visualforce background image not displaying

  19. 19

    Body background image not displaying

  20. 20

    background image not displaying correctly

  21. 21

    Body background image not displaying

  22. 22

    Background Image is not displaying in Div

  23. 23

    Background Image not Displaying in Chrome

  24. 24

    CSS - displaying a dynamic height floated DIV - missing background image

  25. 25

    background-image in HTML, CSS and JavaScript game not displaying

  26. 26

    Firefox Add-On CSS not displaying background-image

  27. 27

    CSS Background Image Not Displaying ( using HTML5 Boilerplate)

  28. 28

    CSS: content not displaying

  29. 29

    drop down menu displaying behind content

HotTag

Archive