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 7016319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:09+00:00 2026-05-27T22:46:09+00:00

lets say i have an horizontal webiste ( http://toniweb.us/gm2/ ) and in a certain

  • 0

lets say i have an horizontal webiste ( http://toniweb.us/gm2/ ) and in a certain point i would like to know how much horizontal width is avaliable,

i made this picture so it’s easier to understand

enter image description here

So i would need to get the EXTRA SPACE’s width

and i am trying like this:

$(window).outerWidth(true)-($('header').outerWidth(true)+$('#nvl1').outerWidth(true)+$('#nvl2').outerWidth(true))

also tried

$(window).width()-($('header').outerWidth(true)+$('#nvl1').outerWidth(true)+$('#nvl2').outerWidth(true))

but in IE8 it’s not returning the same value…

and then i need to apply it to the div, i made this function

function rellenarEspacio(){
    if(lte8){
        var w = $(window).width()-($('header').outerWidth(true)+$('#nvl1').outerWidth(true)+$('#nvl2').outerWidth(true))+$('#nvl2').outerWidth(true);
    }else{
        var w = $(window).width()-($('header').outerWidth(true)+$('#nvl1').outerWidth(true)+$('#nvl2').outerWidth(true));
    }

    //alert(w);
    $('.extra').css({'display':'block'});
    $('.extra').css({'width':w});
    return false
}

but is not using the whole space

any idea what I am missing?

  • 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-27T22:46:09+00:00Added an answer on May 27, 2026 at 10:46 pm

    Explanation

    You’re getting a negative value because… well because that’s correct.

    If you’ve got 3 divs that always take up X amount of space while your viewport is smaller than all the div widths combined, there is no space left.
    To best describe it, I’ve print screened my JSFiddle example:
    Showing some space
    Here you can see there is plenty of space, 235px to be exact.
    While the window’s width is larger than the sum of all the div widths, there is still space left.
    Both window and document show the same width at this point, so both are valid.


    Showing no space
    Here, there is no space left.
    In your case, this would become 530 -(200 + 200 + 200) = -70) empty space.

    Look what happens:
    The window width is actually smaller than the document width. Why?
    Well, because I resized the window to be that small, that’s why.

    The document width on the other hand is still the sum of all those div widths.

    The reason for this, is because you have the size of the viewport, meaning, the size of your window, not the size of the document that contain all your elements.

    So, to conclude: using this $(document).width() instead, should fix the problem.


    Solution

    Here is the example on how it works.
    And here’s my solution.

    function adjustSpace(){
        var iHeaderW = $('header').outerWidth(),
            iNvl1W = $('#nvl1').outerWidth(),
            iNvl2W = $('#nvl2').outerWidth()
            iDocW = $(document).width();
        var iEmptyWidth = iDocW - (iHeaderW + iNvl1W + iNvl2W);
    
        console.log("Empty space: "+iEmptyWidth);        
    
        if(iEmptyWidth <= 0){
            $('.extra').width(0).hide();
            return false;
        }
    
        $('.extra').width(iEmptyWidth).show();
        return true
    }
    

    Additional information

    Before you use the outerWidth() function, you should check out what the documentation has to say:

    This method is not applicable to window and document objects; for these, use .width() instead.

    The reason why IE8 return a different value than the other browsers, is because IE sucks. 🙂
    No, but seriously, IE8 probably has a different box-sizing property and gives you a different result because of it, and you’re using outerWidth(); which, as previously mentioned, is not the correct application for that function.

    Check out this answer.

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

Sidebar

Related Questions

Lets say I have an array like this: string [] Filelist = ... I
Lets say we have something like: <div class=row> <div class=box> <a class=more href=#more/> </div>
The problem: I have a set width and height image Lets say height:160px; width:200px;
let's say I have a matrix (array) like this example, but much larger: 0
lets say I have a viewport with a width of 1000px And in the
Lets say I have a set of model classes like this: public class Person
Lets say I have a p tag like this: <div id = example> <p
lets say i have a list of urls such as http://stackexchange.com https://stackoverflow.com/users/login http://careers.stackoverflow.com http://chat.stackoverflow.com
Lets say I have a class that is doing something like: public class Foo
Lets say I have some markup like this: <html> <head> <style type=text/css> #container {

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.