+---------------------------------------------------+
|+------------++-----------------------------------+|
|| FIXED || NON-FIXED WIDTH DIV ||
|| WIDTH DIV || ||
|+------------++-----------------------------------+|
| REMAINING SPACE IN BROWSER |
| |
+---------------------------------------------------+ Now, as that hopefully shows, I've got a fixed width div floated to the left, it's sitting in the upper-left corner of the browser window. Sitting next to that I have another div, with a non-fixed width. I'm trying to get this non-fixed width div to expand to fill all the remaining space, but have been unable to do so thus far. I don't want to fix the width. Setting the width to a % takes it's value from the container if I'm not mistaken, which results in the (correct but undesired) behavior of it being pushed down below the fixed-width and expanding to fill the browser. So, does anyone know of a solution, or have any ideas where I could look? I'm also going to be a bit of a pain in the a$$ and say I'd like to support as many browsers as possible correctly (at least Opera, Firefox, and IE), and that javascript should be avoided if possible (if there's no other way I'll probably use javascript to calculate an appropriate fixed width instead).
🔒 Locked
[web] CSS Layout - Fluid Width
Advertisement
Original Post
Hi all, I've been trying for a while to get a particular layout to work correctly, but I havn't been able to find any solutions myself, and have been unable to locate any solutions elsewhere either. Basically, I've got a number of divs being used to position content. For simplicities sake, I'll just talk about two for now. I have them layed out something like the following:
That's actually a *lot* trickier than it sounds. Basically you have a two-column layout at the top (left column fixed with) and room below that. I suggest you take a look at http://css-discuss.incutio.com/?page=TwoColumnLayouts over at css-discuss to see a couple of examples on how to accomplish this. http://bluerobot.com/web/layouts/layout1.html looks simple enough.
Edit: http://www.ryanbrill.com/floats.htm looks good too. Just use a short two-column layout at the top, regular page contents below that.
Edit: http://www.ryanbrill.com/floats.htm looks good too. Just use a short two-column layout at the top, regular page contents below that.
Pure CSS is absolutely useless for column-based designs. Until the W3C fixes this aspect of CSS, tables will save you a lot of headaches. Your design will still be valid HTML and, let's face it, none of your users will complain about the usage of tables on your site. box-sizing: border-box (forcing browsers to use an intuitive box model) will also help a great deal in column-based designs.
Jim Price did something similar here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=351608
Is this any good to you?
http://www.gamedev.net/community/forums/topic.asp?topic_id=351608
Is this any good to you?
This doesn't work for you?
Unless I misunderstood, this works in IE, Firefox, and Opera. Setting the right div's margin-left to the same width of the left div wouldn't be a bad idea either, should you want to place a background on the right div.
TEST - leftTEST - right<style type="text/css">#left { float: left; width: 150px; }</style>Unless I misunderstood, this works in IE, Firefox, and Opera. Setting the right div's margin-left to the same width of the left div wouldn't be a bad idea either, should you want to place a background on the right div.
Ok, I'm an idiot. [embarrass]
I had the right div (non-fixed width) floating against the others for some reason, which was causing it to collapse to the size of it's content unless I defined a width. No idea why I didn't spot that one myself, guess I'd just been playing with that markup for too long.
Thanks everyone for the assistance though. [smile]
Heh, I'm one of those 'purists' who avoids tables like the plague when not displaying tabulated data. I personally think the markup looks a lot cleaner without them, and as an added bonus my filesize is just that little bit smaller as well. If the hacks required to do the layout without them got overly out of hand then I'd resort to tables, but thus far I've still got hack-free markup, so I'm happy to continue trying to avoid them.
I had the right div (non-fixed width) floating against the others for some reason, which was causing it to collapse to the size of it's content unless I defined a width. No idea why I didn't spot that one myself, guess I'd just been playing with that markup for too long.
Thanks everyone for the assistance though. [smile]
Quote:
Original posts by benryves and kanzler
[advising use of tables]
Heh, I'm one of those 'purists' who avoids tables like the plague when not displaying tabulated data. I personally think the markup looks a lot cleaner without them, and as an added bonus my filesize is just that little bit smaller as well. If the hacks required to do the layout without them got overly out of hand then I'd resort to tables, but thus far I've still got hack-free markup, so I'm happy to continue trying to avoid them.
Quote:
Original post by Fuzztrek
Unless I misunderstood, this works in IE, Firefox, and Opera. Setting the right div's margin-left to the same width of the left div wouldn't be a bad idea either, should you want to place a background on the right div.
It stops working as soon as you add a margin to either of the top boxes (which I had when I played with some markup to come up with a simple solution -- to no effect).
Also check out http://www.alanwho.com/web-development/css/7-css-xhtml-11-layouts There is only 7 layouts there but they show are pretty good. I refer to the layouts often. Also they dont use absolute positioning like some do, which I dont like.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement