Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Sizing one division relative to another.
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 09 March 2006 :  07:27:23  Show Profile
Been scratching my brain over this one for a couple of weeks now, trying to come up with a solution, to no avail:

I have on a webpage 2 divisions, one floating to the right of the other and what I need to do is set the height of the one on the right to be the same as the one on the left. Sounds easy, you may say, but the problem is that the height of the division on the left is going to be changing from page to page. Using an expression in my CSS would be an ideal solution, if it was a cross-browser feature. Does anybody know of any pure CSS tricks that would help me achieve this (i.e., preferably without resorting to Javascript)?


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 09 March 2006 :  10:33:00  Show Profile  Visit MarcelG's Homepage
Mmmm...I think I've seen one somewhere that does this....Let me google.

quote:
Method 2: Passing the height of an absolute DIV to its relative parent
If you choose to go with all columns set to absolute, now you have the problem of “bottom-section” overwriting “mid-section”.

The workaround I am currently playing with involves a small script. (It is currently on the clunky side, so for now I’m using the CSS-only method above.) The trick is to use the onload event handler in the <body> tag to trigger a little script that reads the height of “mid-col-2” and passes it to “mid-section.” This forces “bottom-section” to start further down the page where it’s supposed to.

The following scripting is bare minimum. (It would be more elegant to have a script that walks the document’s DOM tree, applying itself to every container of a certain type. In this way you might pass the height of the longest column instead of arbitrarily passing only “mid-col-2” and you could perform the transfer to any number of relative container DIVs.) If a clever JavaScripter wants to finish the job, I’d be obliged. In the mean time, here’s the little hack:



function inherit(objidParent,objidChild,objidGrandchild) {
if (document.layers) {
alert('sorry, no pretty layouts for netscape 4');
}
else if (document.getElementById) {
  
Parent = document.getElementById(objidParent);
Child = document.getElementById(objidChild);
Grandchild = document.getElementById(objidGrandchild);

Parent.style.height = Child.offsetHeight + 'px';
Grandchild.style.display = 'block';

return true
}
  }
From: http://www.alistapart.com/articles/flexiblelayouts/

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 09 March 2006 10:38:19
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 09 March 2006 :  11:23:08  Show Profile
Thanks, Marcel Have my own javascript function in there at the moment, though, which resizes the smaller of the 2 divisions to be the same height as the larger but I prefer not to rely on JS for layout purposes, for those that may have it disabled in their browsers.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

-gary
Development Team Member

406 Posts

Posted - 09 March 2006 :  11:45:40  Show Profile
JS is the only way to go really. If you're just looking to make backgrounds match up, you can use a container div with a background image to get the same effect. Using a clearing div after and everything will fall below the two instead of floating to the bottom of the shorter div if that's another problem.

KawiForums.com


Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 09 March 2006 :  11:54:02  Show Profile
JS it'll have to be, so At least until more browsers support expressions in CSS


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07