CSS三列高度自适应布局

本文详细介绍了HTML页面布局中使用div元素和CSS样式进行布局的方法,包括块级元素的浮动、清除以及针对不同浏览器的兼容性处理。同时,阐述了如何通过CSS实现响应式设计,使网页在不同设备上呈现最佳视觉效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;
	}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值