Solved

resize content not working

Posted on 2013-05-10
2
183 Views
Last Modified: 2013-05-10
I have 4 divs on my page which use 100% of the page width:-

divLogo
menuBarHolder
bodyContents
divFooter

I want to resize bodyContents to use available height remaining on the window, so have written the following code:-
    $(document).ready(function () {
        $(window).resize(resizeContent());
    });
    $(window).load(function () {
        resizeContent();
    });

    function resizeContent() {
        $("#bodyContents").css("height",$(window).height() - ($("#menuBarHolder").height() + $("#divFooter").height() + $("#divLogo").height()) + "px");
    }

Open in new window


Which I thought would sum up "divLogo", "menuBarHolder", and "divFooter" and subtract it from the window height and that would be the height of "bodyContents", however I still have a vertical scroll bar.

On debugging "divLogo" has a height of 0, however it has a logo image inside the div:-
<div id="divLogo"><img src="img/Logo.png" /></div>

Open in new window


Also when the window is resized it doesnt seem to run the resizeContent() function .

Im a little confused, because as far I can see this should work, and it is moving the divFooter down so I know its initially running, just wrong and not running when resized.

Any ideas?
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39155648
replace : $(window).resize(resizeContent());
by : $(window).resize(resizeContent);

and set the dimension of your logo :
<div id="divLogo"><img src="img/Logo.png" style="width:320px;height:200px;" /></div>
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39155652
    $(document).ready(function () {
    });
    $(window).load(function () {
        resizeContent();
    }).resize(resizeContent);

    function resizeContent() {
        $("#bodyContents").css("height",$(window).height() - ($("#menuBarHolder").height() + $("#divFooter").height() + $("#divLogo").height()) + "px");
    }

Open in new window

0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question