html+css三栏布局-浮动方法

第一种处理方式

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>三栏布局-浮动方法</title>
<style type="text/css">
* { margin:0; padding:0;}
#wrap { 
  background: grey;
   padding-left: 200px;
   padding-right: 300px;
   min-height: 1000px;
}
#main { float:left; width:100%; height: 1000px; background: blue;}
#left, #right { position:relative;}
#left { width:200px; background:yellow;height:800px;float:left; margin-left:-200px;left:-100%;}

#right { width:300px; background:red;height:400px;float:right; margin-right:-300px;}
</style>
</head>
<body>
<div id="wrap">
 <div id="main">
 	<p>content</p>
 </div>
 <div id="left">
  	<p>left</p>
 </div>
 <div id="right">
 	<p>right</p>
 </div>
</div>
</body>
</html>


第二种处理方式


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>三栏布局-浮动方法</title>
<style type="text/css">
* { margin:0; padding:0;}
#wrap { 
  background: grey;
   padding-left: 200px;
   padding-right: 300px;
   min-height: 1000px;
}
#main { float:right; width:100%; height: 1000px; background: blue;}
#left, #right { position:relative;}
#left { width:200px; background:yellow;height:800px;float:left; margin-left:-200px;}

#right { width:300px; background:red;height:400px;float:right; margin-right:-300px;right:-100%;}

</style>
</head>
<body>
<div id="wrap">
 <div id="main">
 	<p>content</p>
 </div>
 <div id="left">
  	
 </div>
 <div id="right">
 	
 </div>
</div>
</body>
</html>


你可能感兴趣的:(html+css三栏布局-浮动方法)