If you want to create a full screen background image without using jQuery or Javascript, you can simply use a full screen div with a background image.
Check out this working JSFiddle
To implement this, you just need to add the following code:
<div class="fullscreenimg"></div>
And then style it using the following CSS:
.fullscreenimg {
background-image:url(IMAGEURL);
background-size:cover;
width:100%;
height:100%;
}
UPDATE: Please note that while this method works in modern browsers and some older versions, it may not be fully supported in older versions like IE 6-8.
For compatibility with older browsers, you can alternatively use an <img>
element positioned absolutely with top
, bottom
, left
, and right
all set to 0
. However, this method will stretch the image rather than resize it.