|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
div stretching
I know I've seen lots of questions on div sizing and positioning, but I apparently haven't been able to follow them. So I wrote out some very basic containers, and am looking for some very basic answers, even if they're only "no, it won't work."
So let's say I have a layout like this: PHP Code:
What I want to happen is for the orange div (floated div 2) to fill the rest of the width of the surrounding blue div (centered div). I know with this simple example I can simply set the pixel width, but I want to eventually make it more dynamic, allowing for variable sizes, like if I set the blue div to be a percentage instead of a fixed width. Any ideas? (Even links to appropriate threads are appreciated!) Thanks! (edit: had to update "centered div" to be firefox compatible)
__________________
Proud member of the T.S.N.B.U.F.L (tables should not be used for layout) alliance. "Only use elements for their intended purpose. You wouldn't try to make coffee with a telephone, would you?" -Me Last edited by TheJim01 : June 18th, 2004 at 12:09 AM. |
|
#2
|
||||
|
||||
|
Two solid methods here:
1. View it --> http://www.bertelsen.ca/media/devsh...im01-part1.html PHP Code:
The coding is slighty different, your main problem is that you need to choose to base one proportion off of another. The method shown above uses a 20% 80% split (adding borders messes with an exact fit, just fyi) between green and orange, respectively. 2. View it --> http://www.bertelsen.ca/media/devsh...im01-part2.html However, another method would be to position the orange div in a manner that forces it to allow the green to be shown, and positions it properly in the container by using a left margin... shown here: PHP Code:
I would suggest method #2 Note: Please do remember that IE is bugged, and that when you specify "text-align:WHATEVER;" it automagically applies that alignment to the block level element and not JUST to the inline elements as it should. Is that what you were looking for?
__________________
The Standards! CSS 2 - CSS 3 - w3c CSS Validator - XHTML 1.1 - HTML 4.01 - w3c (X)HTML Validator - ActionScript Reference Links! Bert's Door and Lock Service | Brandon Erik Bertelsen | TextPattern Last edited by 1beb : June 22nd, 2004 at 01:09 AM. |
|
#3
|
||||
|
||||
|
Yeah, I didn't really want to do the percentage split since the one column has to be the set width. (and yes, I always calculate in borders
) I had also played with using absolute positioning and 100% width, with 100px padding for the orange div.Unfortunately, neither method quite works. The absolute positioning has too many quirks (it caused some strange rendering in both IE and FF), and your #2 method looks good in IE, but craps out in FF--the orange div extends past the blue div, and so any internal text will flow outside the blue div as well. Who wants to start a W3C petition for a "width: fill_rest_of_unassigned_area;" style option? haha I'm trying to do this so I can move away from tables for my site, however I'm starting to think that div's are more hassel than they're worth for this case, especially when tables have so many good alignment qualities, when you know how to use them properly... Thanks for your sugestions, though. ![]() Last edited by TheJim01 : June 21st, 2004 at 02:49 PM. |
|
#4
|
||||
|
||||
|
3. View it --> http://www.bertelsen.ca/media/devsh...im01-part3.html
This time I think I got it. Please pay attention to the class with [attributes] it's a very sheepish little hack to force IE to ignore certain style selections... works like a charm in both IE WITH, the borders, hence I got some screwy mutations on the original idea... but at least I was heading in the right direction... the hack I'm reffering to is commented in the document whose link is... PHP Code:
Last edited by 1beb : June 22nd, 2004 at 01:10 AM. Reason: /me flexes his css |
|
#5
|
||||
|
||||
|
Very cool. Works exactly like I wanted it to, and teh example will definately help in further development. I'll have to remember that attribute hack. Thanks a million!
![]() |
|
#6
|
||||
|
||||
|
Quote:
No problem TEHjim01, ![]() haha, I do that all the time... it's a disease I swear! An innocuously spreading one at that! |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > div stretching |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |