Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Resizable background image

Featured Replies

Hi, I'm new here, and I've been doing this webdesign thing for 6 to 7 months now.

I'm the worst. Literally. I'm always looking for this jquery and javascript to resize the background and never seem to work out.

 

Here's one page a tryed to follow trhough http://growmedia.ca/blog/2009/10/14/resizable-full-browser-background-image-with-jquery-preserving-aspect-ratio/

 

I first just copied the javascript they first put in there. After that I did copy step by step the codes and in the end it didnt work.

I sincerely hate jquery and javascript, but it's something I need to learn

Can someone make me a newbie guide for this " resizable background" ?

 

I put the codes together and ended up with this:

 

 

(function($){

//code goes here

 

$(document).ready(function() {

$('#bg').resizenow();

});

 

$(window).bind("resize", function(){

$('#bg').resizenow();

});

 

var startwidth = 1440;

var startheight = 956;

var browserwidth = $(window).width();

var browserheight = $(window).height();

if ((browserheight/browserwidth) > ratio) {

$(this).height(browserheight);

$(this).width(browserheight / ratio);

$(this).children().height(browserheight);

$(this).children().width(browserheight / ratio);

} else {

$(this).width(browserwidth);

$(this).height(browserwidth * ratio);

$(this).children().width(browserwidth);

$(this).children().height(browserwidth * ratio);

}

$(this).children().css('left', (browserwidth - $(this).width())/2);

$(this).children().css('top', (browserheight - $(this).height())/2);

$(document).ready(function() {

$("div#bg").supersize();

});

})(jQuery);

 

 

 

I changed the "supersize" tag for "bg" that it is actually my div for the resize. I tryed not doing that too, but it didn't work anyway.

Please help.

Did you add the jQuery library to the <head> section of your page?

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

You can do with Pure CSS. No JS required.

 

Add clss into your css and put Background image at the end of the body tag.

.bgHemz {

width: 100%;

height: 100%;

position: fixed;

top: 0;

left: 0;

z-index: -5000;

}

<img src="bgimages.jpg" class="bgHemz" width="1024" height="763" />

 

Hopefully, your issue will be solve.

 

Please reply.

else you can add following code in css

 

 

body{

background: url(bgimages.jpg) no-repeat left top;

}

 

He want resizable background so you cant write no-repeat.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.