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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With