How to make background image repsonsive

Posted on 2013-12-16
Last Modified: 2013-12-30

I dont really know much css and i was looking at this website

and I was wondering if you could point me to the css in this website that makes the background image responsive. I am not sure if it is truly responsive but it seems to resize based on browser resolution

Question by:andieje
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 30

Accepted Solution

Alexandre Simões earned 250 total points
ID: 39721174
This website uses this jquery plugin:

The original background image is:

and the plugin initialization can be found on line: 52 of the page source code.
LVL 16

Assisted Solution

hankknight earned 250 total points
ID: 39722916
Here is a pure CSS solution that does not require jQuery or JavaScript:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<style type="text/css">
html, body, div {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
height: 100%;
width: 100%;
background: #000 url('') no-repeat scroll 50% 50%;
background-size: 100%;

Open in new window

The trick is: background-size: 100%;

Expert Comment

ID: 39724729
I would do this using just the CSS, similar to what hankknight has done.

I would modify it slightly to use different images at different screen sizes. This would keep the download size smaller for people on mobile devices.

@media all and (max-width: 480px) {body 
	background-image: url(../images/MY-SmallImage.png) 
        background-size: cover;

@media all and (min-width: 481px) and (max-width: 768px)  {body
	background-image: url(../images/MY-MediumImage.png) 
        background-size: cover;
@media all and (min-width: 769px) {body 
	background-image: url(../images/MY-LargeImage.png) 
        background-size: cover;

Open in new window

This gives you a different images to download depending on screen size.
Set the image size to whatever works best for the image you are using. hankknight's link to w3c explains the different background size options.
LVL 16

Expert Comment

ID: 39724760
I like the approach provided by itkadmin better than the approach I posted because it gives you the ability to use a smaller image for smaller devices which saves bandwidth and improves performance.

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question