After reading this informative resource, all you need to do is create a div with a unique id and insert the image within as demonstrated below:
<div id="bg">
<img src="yourimage.jpg" alt="">
</div>
Next, apply these styles:
#bg {
position: fixed;
top: 0;
left: 0;
/* Maintain aspect ratio */
min-width: 100%;
min-height: 100%;
}
.back {
/* Define background fill rules */
min-height: 100%;
min-width: 1024px;
/* Ensure proportional scaling */
width: 100%;
height: auto;
/* Positioning setup */
position: fixed;
top: 0;
left: 0;
}
By following these steps, you should achieve the desired effect.
You can observe the implementation live and experiment here (click the full-screen arrow in the corner next to "Auto-run js" for optimal viewing)..