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
https://forums.phpfreaks.com/topic/256126-jquery-height-issue/
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
https://forums.phpfreaks.com/topic/256126-jquery-height-issue/#findComment-1313291
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.