2种三栏布局那种好~

一、第一种是现在普遍用的方式,利用左右浮动

<!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:0px; padding:0px; text-align:center}
.header { margin:0px auto; margin-top:10px; width:958px; height:50px; border:1px solid #f60; line-height:50px;}
.warp { margin:0px auto; width:960px; margin-top:10px; overflow:hidden;}
.left_side { width:735px; float:left}
.right_side { width:215px; height:100px; background-color:#0FF; float:right}
.left { width:215px; height:200px; background-color:#FCF; float:left}
.right { width:510px; height:300px; background-color:#FFC; float:right}
</style>
</head>

<body>
<!--顶部-->
<div class="header">页面头部</div>
<!--内容-->
<div class="warp">
  <div class="left_side">
    <div class="left">第一栏</div>
    <div class="right">第二栏</div>
  </div>
  <div class="right_side">第三栏</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:0px; padding:0px; text-align:center}
.header { margin:0px auto; margin-top:10px; width:958px; height:50px; border:1px solid #f60; line-height:50px;}
.warp { margin:0px auto; width:960px; margin-top:10px; position:relative}
.left { width:215px; height:200px; background-color:#FCF; float:left}
.mid { position:absolute; top:0px; left:225px; width:510px; height:500px; background-color:#3CF}
.right { width:215px; height:300px; background-color:#FFC; float:right}
</style>
</head>

<body>
<!--顶部-->
<div class="header">页面头部</div>
<!--内容-->
<div class="warp">
    <div class="mid">第二栏<br />(优先加载)</div>
    <div class="left">第一栏</div>
    <div class="right">第三栏</div>
</div>
</body>
</html>

你可能感兴趣的:(定位,布局,三栏)