Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS fluid 'column'

Tags:

css

layout

Whats the best way to get this layout in CSS? imagine that I have three divs, two divs inside another.. of the two inner divs, the first one has a specific width set, and the second div is expected to take up the remaining space.

Generally I'd end up setting a specific width on the second column, and manage updating this in the end that the containing div width changed.

If I float the fixed but not the fluid, the fluid column will wrap underneath the fixed div (not what is wanted).

+-------+  +--------------------------------------+
| fixed |  |                                      |
+-------+  |               fluid                  |
           |                                      |        
           |                                      |
           +--------------------------------------+

<div>
  <div>fixed</div>
  <div>fluid</div>
</div>

This has to be an entirely css solution, no javascript frameworks- and ideally works on most commonly used browsers with minimum 'hackage' (if at all).

Hope the ASCII art works,

Thanks.

like image 449
meandmycode Avatar asked Apr 23 '09 19:04

meandmycode


People also ask

How do I make fluid in CSS?

Use the CSS property max-width to create boundaries for a fluid page. By setting a percentage width and a fixed pixel max-width , the content wrapper will always be relative to the screen size, until it reaches the maximum size, 800px in this example, to keep the content wrapper from extending beyond that.

How do you make a column responsive in CSS?

Declare both (recommended) Use column-count and column-width together for the best control over CSS columns. You can declare each property or use the shorthand columns . When both properties are declared, column-count is the maximum number of columns and column-width is the minimum width for those columns.

What is fluid grid CSS?

A fluid grid layout provides a visual way to create different layouts corresponding to devices on which the website is displayed. For example, your website is going to be viewed on desktops, tablets, and mobile phones. You can use fluid grid layouts to specify layouts for each of these devices.


1 Answers

the markup

<div id="fixed">fixed content</div>
<div id="fluid">fluid content</div>

the css

#fixed {
  float: left;
  width: 13em;
  margin-right: -14em;
}
#fluid {
  margin-left: 14em;
}

That should do the trick. I use it on my personal site. The margins make it all stay on the same level.

like image 59
geowa4 Avatar answered Oct 07 '22 15:10

geowa4