I want to achieve the following:
- "Main" div and sidebar "div" should have same height, with minimum height (maybe browser's screen height or 700px) maximum height is not limited - according to the contents.
- The "content" div should wrap them(same height and width of both of them)
Markup:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet2.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrap">
<div id="content">
<div id="main">
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
</div>
<div id="sidebar"></div>
</div>
<div id="footer">
<p>Footer</p>
</div>
</div>
</body>
</html>
CSS:
body, html
{
margin: 0;
padding: 5px;
color: #000;
background: #ace187;
height:100%;
}
#wrap
{
width: 752px;
height:100%;
margin: 0 auto;
}
#content
{
border: 1px solid #000000;
height: 100%;
background-color: #dbeef8;
}
#main
{
float: left;
width: 506px;
padding: 10px;
border: thin dashed green;
height: 100%;
}
#sidebar
{
border: thin dashed #FF0000;
float: right;
width: 200px;
padding: 10px;
height: 100%;
}
#footer
{
clear: both;
padding: 5px 10px;
background: #cc9;
}
note: there is a "wrap" div and it's also needed because it wraps a header that i omitted.
Though I am not fond of CSS expressions
The following is the answer I got from the author of the "stupid tables" page http://hotdesign.com/seybold/everything.html whom you cited in your comments. I figured that if he was going to go to the effort of giving this advice to people, I might as well ask him for a hint on how to solve this particular problem.
I'm happy to see he agrees with me that it's not practical to ALWAYS steer clear of tables.
Equal height columns with pure CSS. I added a min-height since you asked for it. There is the one IE6 hack purely for the min-height since IE6 doesn't understand min-height, but treats height as min-height. This is a striped down version of this.. http://matthewjamestaylor.com/blog/equal-height-columns-2-column.htm
To answer your second question:
Your first question is a bit harder. In my order of preference (depending on circumstances):
Cross-browswer pure css is not possible I´m afraid.
I keep reading about sleazy CSS hacks to achieve this, or fake it.
At the risk of drawing the ire of the CSS purist crowd, whenever this comes up for me, I use tables. "Semantics and presentation" be damned, so long as CSS doesn't offer sensible solutions for commonplace problems like this, I'll stick with what works.
If you could guarantee that your page will always be shown in a JavaScript-enabled browser, you could do the sizing dynamically. But this would be far from my first choice.