Jump to content

How to use a jquery


Recommended Posts

Hello

Yesterday i had put a question in a other topic but i have found a solution i only dont know how to intergratie it

this was my question


i hope someone can help me, i want a picture as background, so far no trouble but i want the picture to show on al browsers and all resolution

but then i got a problem because the picture is not showing when someone has a small screen, is there a way to make sure the hwole picture is also showing with al smal screen?

i have included the pictures screen 1 is how a want it and screen 2 is with small screen

I have found a solution but i don't know where en how i can integrate it )jquery)

this could be the solution is there someone who can helpe where i have to put these codes in witch files etc?

first code:





seccond code;

#bg { position: fixed; top: 0; left: 0; }
.bgwidth { width: 100%; }
.bgheight { height: 100%; }



third code

$(function() {   

       var theWindow        = $(window),
           $bg              = $("#bg"),
           aspectRatio      = $bg.width() / $bg.height();

       function resizeBg() {

               if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                   $bg
                       .removeClass()
                       .addClass('bgheight');
               } else {
                   $bg
                       .removeClass()
                       .addClass('bgwidth');
               }

       }

       theWindow.resize(function() {
               resizeBg();
       }).trigger("resize");

});

38146_xAVrlSpBP0Hdo4OssSDG_t

38147_A0lGcx0r3jLW8egR4Rv5_t

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...