September 19, 201214 yr 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.
September 20, 201214 yr 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>
September 26, 201214 yr 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.
September 26, 201214 yr else you can add following code in css body{ background: url(bgimages.jpg) no-repeat left top; }
September 26, 201214 yr 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.
September 26, 201214 yr yes..Bro you are right, instead use body{ background: url(bgimages.jpg) left top; }
Create an account or sign in to comment