This is a discussion on "Completely Flexible Columns" within the Web Page Design section. This forum, and the thread "Completely Flexible Columns are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Completely Flexible Columns
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Completely Flexible Columns
I've got two columns set up using CSS floats (2 divs - left + right). I don't want either to have a fixed pixel width or a fixed percentage width. Sometimes the left column will be wider, sometimes the right. I haven't figured out what to do so that the left column doesn't expand to the full width of the container div and push the right float beneath it. Do you know what I mean and do you have any suggestions about how to do this? Thanks a lot!
Example: I have an 800 pixel container with a left-floated div and a right-floated div. One or both columns include images of various widths (but less than 800 px). What if I want the column that the image is in to automatically adjust to fit the image (no more, no less wide)? Last edited by Geoff Myers; Sep 30th, 2006 at 03:12. |
|
|
|
#2
|
||||
|
||||
|
Re: Completely Flexible Columns
I believe that display: table; isn't supported in a lot of browsers, but some testing should let you know. This is the only way to do what you want unless you want to resort to tables:
|
|
#3
|
|||
|
|||
|
Re: Completely Flexible Columns
I believe a cross browser solution should be to change the <div>'s from their default block element to inline elements.
Add this to your div styling:
|
|
#4
|
||||
|
||||
|
Re: Completely Flexible Columns
He's asking for columns to behave like table columns. All that display: inline will do is make them sit next to each other if the content isn't wide enough. The moment that the content of both <div>'s exceeds the browser width, the right <div> will move underneath the other one.
|
|
#5
|
|||
|
|||
|
Re: Completely Flexible Columns
Yes I agree but as you said in another post, there are always options to explore.
Have a look at this basic code, run it in your browser and read the text content of the divs.
|
|
#6
|
||||
|
||||
|
Re: Completely Flexible Columns
I agree, but CSS doesn't work like tables. There is no way to get one <div>'s width to respond to another's with just valid CSS (aside from the mentioned display: table; properties which aren't supported in IE). Each side has it's pros and cons, this is just one more mark against CSS.
I did find a way to do what you're asking using CSS hacks, but I would never use it because I think hacks are the devil http://snook.ca/technical/div_tables/fluid3col.html It's not exactly what you want, but it's got everything you need to make it so. |
|
#7
|
|||
|
|||
|
Re: Completely Flexible Columns
display:table; =P
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#8
|
||||
|
||||
|
Re: Completely Flexible Columns
The table properties don't work in IE. Even in IE6.
|
|
#9
|
|||
|
|||
|
Re: Completely Flexible Columns
http://www.newbeginningsdesign.com/s...mn_layout.html
change the pixel values to percentages and it should be fine.
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#10
|
||||
|
||||
|
Re: Completely Flexible Columns
Oh, he's looking for something that changes width depending on the content. No set widths, in either pixels or percentages.
|
|
#11
|
|||
|
|||
|
Re: Completely Flexible Columns
It changes with content. Of course, it could be modified to change even more i.e. width instead of just height. Just providing a building base to form a complete solution.
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#12
|
||||
|
||||
|
Re: Completely Flexible Columns
I'm confused. How can that layout turn into a table-column-like layout?
|
|
#13
|
|||
|
|||
|
Re: Completely Flexible Columns
Well, it could be adjusted to use the CSS 3 multi column module for one if you are concerned with content wrapping. Use a snippet of JS to make it work in IE and it does. other than that, just use a damn table. =)
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#14
|
||||
|
||||
|
Re: Completely Flexible Columns
This one works fine, though.
http://snook.ca/technical/div_tables/fluid3col.html You don't really notice anything spectacular until you shrink your browser width so the right and left columns change sizes as well as the middle one. |
![]() |
| Tags |
| columns |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Column count not matching, completely confuzzled | CloudedVision | Databases | 4 | Mar 21st, 2008 17:32 |
| CSS Completely Validated, BLANK page in IE | Sulman | Web Page Design | 7 | May 16th, 2007 06:30 |
| Rollovers don't work until Quicktime completely downloads!?! | Alcivar | Web Page Design | 5 | Apr 26th, 2007 22:37 |
| Completely baffled by footer in Firefox | Jellytot | Web Page Design | 7 | Mar 29th, 2007 15:23 |