Jump to content

jQuery Height Issue


OAFC_Rob

Recommended Posts

I am trying to get the height of a div as the layout stay the same, but content alters from page pushing down a advert.

 

I know I can use the following;

 

$(".mainGenericContentContainer").css("height") to get the pixel height of the div

$(".mainGenericContentContainer").height() to get the height, but can have a few issues across browsers

$(".mainGenericContentContainer").outerHeight() to get the height ignoring margins, padding etc..

$(".mainGenericContentContainer").innerHeight() to get marging, padding and height of the div

 

So I thought it would be pretty simple target the div, get the height and alter the top of the relative div containing my advert. However the height returned for my div is something like 1146 when firebug under the layout section says the computed box height is 356

 

I have looked at the div and a direct height isn't being set with it inheriting from the parent, but a min height is being set. When I manually force the height to 500px on the div it seems to work.

 

Any ideas of how to get around this issue

Link to comment
Share on other sites

Right I have an update, nto a full solution / explaination of what is going on but a hack around it.

 

When I do dump out the height of the content container on document.ready it is something like 949 but when I have mousemove on document it comes out at the true height of the content container which is something like 271.

 

I have ensured the parent divs etc... all have height set to auto but that doesn't seem to have helped.

 

Any ideas of what is going on??

 

Coding

 

$(document).ready(function()
{  

    $("#test").html($(".content").height());


    $(document).mousemove(function()
    {
        $("#test").html($(".content").height());
    });
   
});

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.