Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5971949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:35:21+00:00 2026-05-22T20:35:21+00:00

I am trying to create an flexibg image but it is not working. I

  • 0

I am trying to create an flexibg image but it is not working.

I have followed this guide: http://kimili.com/journal/flexible-scalable-background-image
You can see the problem here:
http://mobilhimlen.dk/

My flexi.js:

var flexiBackground = function(){

/**
    CONFIGURATION:
    Define the size of our background image
*/
var bgImageSize = {
    width : 1050,
    height : 800
};

/**
    Declare and define variables
*/ 
var $window,
    $body,
    imageID = "expando",
    tallClass = 'tall',
    wideClass = 'wide',
    $bgImage, $wrapper, img, url, imgAR;

/**
    Are we dealing with ie6?
*/
var ie6 = ($.browser.msie && parseInt($.browser.version, 10) <= 6);

/**
    Set up the action that happens on resize
*/
var resizeAction = function() {
    var win = {
        height : $window.height(),
        width : $window.width()
    };

    // The current aspect ratio of the window
    var winAR = win.width / win.height;

    // Determine if we need to show the image and whether it needs to stretch tall or wide
    if (win.width < bgImageSize.width && win.height < bgImageSize.height) {
        $body
            .removeClass(wideClass)
            .removeClass(tallClass);
    } else if ((win.w < bgImageSize.width && win.height >= bgImageSize.height) || (winAR < imgAR)) {
        $body
            .removeClass(wideClass)
            .addClass(tallClass);
        // Center the image
        $bgImage.css('left', Math.min(((win.width - bgImageSize.width) / 2), 0));
    } else if (win.width >= bgImageSize.width) {
        $body
            .addClass(wideClass)
            .removeClass(tallClass);
        $bgImage.css('left', 0);
    }

    // Need to fix the height of the wrapper for IE6
    if (ie6) {
        $wrapper.css('height', win.height);
    }
};

return {

    /*
        Sets up the basic functionality
    */
    initialize : function() {

        // No need for any of this if the screen isn't bigger than the background image
        if (screen.availWidth <= bgImageSize.width || screen.availHeight <= bgImageSize.height) {
            return;
        }

        // Grab elements we'll reference throughout
        $window = $(window);
        $body = $('body');

        // Parse out the URL of the background image and drop out if we don't have one
        url = $body.css('background-image').replace(/^url\(("|')?|("|')?\);?$/g, '') || false;  
        if (!url || url === "none" || url === "") {
            return;
        }

        // Get the aspect ratio of the image
        imgAR = bgImageSize.width / bgImageSize.height;

        // Create a new image element
        $bgImage = $('<img />')
                    .attr('src', url)
                    .attr('id', imageID);

        // Create a wrapper and append the image to it.
        // The wrapper ensures we don't get scrollbars.
        $wrapper = $('<div></div>')
                        .css({
                            'overflow' : 'hidden',
                            'width' : '100%',
                            'height' : '100%',
                            'z-index' : '-1'
                        })
                        .append($bgImage)
                        .appendTo($body);

        // IE6 Doesn't do position: fixed, so let's fake it out.
        // We'll apply a class which gets used in the CSS to emulate position: fixed
        // Otherwise, we'll simply used position: fixed.
        if (ie6) {
            $wrapper.addClass('ie6fixed');
        } else {
            $wrapper.css({
                'position' : 'fixed',
                'top' : 0,
                'left' : 0
            });
        }

        // Set up a resize listener to add/remove classes from the body 
        $window.bind('resize', resizeAction);

        // Set it up by triggering a resize
        $window.trigger('resize');
    }
};
}();

$(document).ready(flexiBackground.initialize);

And my html:

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
     <script type="text/javascript">
                    $(document).ready(function() {

                      // simple example, using all default options
                      $('div.expandable').expander({slicePoint:       0});

                    });
                    </script>
                            <style type="text/css" media="screen">
                    body { 
                            padding: 0;
                            margin: 0;
                            background-image:url(../images/bg_page_defaults.jpg);
                            background-position: top center; 
                            background-repeat: no-repeat; 
                            background-attachment: fixed;
                            margin-top:50px;
                    }

                    img#expando { 
                            position: absolute; 
                            display: none; 
                            z-index: 1; 
                            -ms-interpolation-mode: bicubic; 
                    } 

                    .wide img#expando, 
                    .tall img#expando { 
                            display: block; 
                    } 

                    .wide img#expando { 
                            width: 100%; 
                            height: auto; 
                    } 

                    .tall img#expando { 
                            width: auto; 
                            height: 100%; 
                    }

                    .ie6fixed {
                            position: absolute;
                            top: expression((ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + 'px') !important;
                    }

            </style>

    </script><script type="text/javascript">

        var border = RUZEE.ShadedBorder.create({ corner:8, shadow:16,  border:2 });

        border.render('round_me');

</script>
</head>
<body>

<script src="flexibg.js" type="text/javascript" charset="utf-8"></script>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:35:22+00:00Added an answer on May 22, 2026 at 8:35 pm

    Dont know what where wrong. Think I did update Jquery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a small http proxy service. This is not working so well.
I am trying create alert dailog using glade,but its not working .am i doing
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I am trying create my custom Style spinner with help of this site. But
Trying to create a user account in a test. But getting a Object reference
I'm trying create a RCP Application with Eclipse, but I can't get past the
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I'm trying create a new file with a Java Applet, but I don't know
Trying to create the following routine in MySQL Workbench yields a This object's DDL
I'm trying create this function such that if any key besides any of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.