Elastic layout with max-width and min-width using grid based design
I want to develop 4 column layout ( in addition to mastead and footer which takes the full available width of the page) such that right-most column is fixed at 200px and others are fluid subject to min-width = 960px and max-width= 1216px.
So this means as long as the browser window is greater than 960 and less than 1216 px wide, the layout acts like liquid layout. Once the browser window is larger than 1216, it acts as fixed layout with the width= 1216px and the page centered in the browser viewport. If the browser window is shrunk to less than 960px, horizontal scrollbar at bottom would appear because min-width is 960px.
I liked the grid system of开发者_如何学C developing website layout (example http://960.gs/).
The doctype on my webpage would be <!DOCTYPE html>
(aka html5 doctype)
The solution should work for IE 6 7 8 9 and FF, Safari, Chrome, Opera.
Hopes this makes it clear what I am looking for.
What is the solution to this problem based on the conditions given above?
I researched google but could not find any solution. I come across solution like 3 column with max-width but without grid system and looked too clumsy.
Later I have to add support for small screen (Mobile devices) which would require setting some column to display:none and stacking other columns on top of each other by using media queries but first I need to get past above problem.
I tested this in IE7/8 and recent versions of Chrome, Firefox, Opera, Safari.
This will not work in IE6 (as @meagar said) because of min-width
and max-width
- there are plenty of resources online detailing hacks to get around this. I'm not going to expend effort on doing this myself unless the rest of my code is correct for you. Also, I have no interest in using a CSS grid system.
Live Demo (with taller right column)
Live Demo (with taller fluid column)
HTML:
<div id="container">
<div id="header">header</div>
<div id="fluidColumnContainer">
<div class="column">column 1</div>
<div class="column">column 2</div>
<div class="column">column 3</div>
</div>
<div id="fixedColumn">i'm 200px wide!<br />o<br />o<br />o<br />o</div>
<div id="footer">footer</div>
</div>
CSS:
html, body {
margin: 0;
padding: 0;
border: 0
}
#container {
margin: 0 auto;
min-width: 960px;
max-width: 1216px;
overflow: auto
}
#fluidColumnContainer {
padding: 0 200px 0 0
}
#fixedColumn {
width: 200px;
float: right
}
.column {
float: left;
width: 33%
}
#header {
height: 90px
}
#footer {
height: 90px;
clear: both
}
精彩评论