CSS三列高度自适应布局

HTML Output

<div id="block_1">
	...
</div>
<div id="block_2">
	...
</div>
<div id="block_3">
	...
</div>

CSS Rules

#block_1
	{
	float: left;
	width: 34%;
	margin-left: 33%;
	}
* html #block_1
	{
	display: inline;
	}
#block_2
	{
	float: left;
	width: 33%;
	margin-left: -67%;
	}
#block_3
	{
	float: left;
	width: 33%;
	}
#footer
	{
	clear: both;
	}
* html body
	{
	margin: 0;
	padding: 0;
	}
* html #footer
	{
	position: relative;
	}

 

 

带wrapper:

HTML Output

<div id="wrapper">
<div id="block_1">
	...
</div>
<div id="block_2">
	...
</div>
<div id="block_3">
	...
</div>
</div>

CSS Rules

body
	{
	direction: rtl;
	}
#block_1
	{
	float: right;
	width: 34%;
	margin-right: 33%;
	}
* html #block_1
	{
	display: inline;
	}
#block_2
	{
	float: right;
	width: 33%;
	margin-right: -67%;
	}
#block_3
	{
	float: right;
	width: 33%;
	}
/* we need this for IE 5.01 - otherwise the wrapper does not expand to the
necessary height (unless fixed, this problem becomes even more acute 
weirdness as the method is enhanced */
#wrapper
	{
/* Normally a Holly-style hack height: 1% would suffice but that causes 
IE 5.01 to completely collapse the wrapper - instead we float it */
	float: left;
/* NB. possibly only IE 5.01 needs to get this float value - otherwise 5.5 sometimes 
(I saw it happen many moons ago) makes the width of wrapper too small 
the float: none with the comment is ignored by 5.01,
5.5 and above see it and carry on about their business
It's probably fine to just remove it, but it's left here 
just in case that many moons ago problem rears its head again */
	float/**/: none;
	}
/* easy clearing */
#wrapper:after
	{
	content: '[DO NOT LEAVE IT IS NOT REAL]'; 
	display: block; 
	height: 0; 
	clear: both; 
	visibility: hidden;
	}
#wrapper
	{
	display: inline-block;
	}
/*\*/
#wrapper
	{
	display: block;
	}
/* end easy clearing */
#footer
	{
	clear: both;
	}

 

你可能感兴趣的:(高度自适应)