首頁  >  文章  >  web前端  >  css頁面中左中右分欄佈局的實現

css頁面中左中右分欄佈局的實現

不言
不言原創
2018-06-21 16:36:233108瀏覽

頁面左中右分欄佈局在目前的網頁佈局中是比較常見的,下面就與大家分享兩個不錯的方法可以實現左中右分欄佈局,代碼很詳細,需要的朋友可不要錯過

以下程式碼複製貼上即可使用:
範例一: 

<!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 charset="gb2312" /> 
<style type="text/css"> 
.page_center { 
width:100%; 
} 
#nav { 
background-color:red; 
height:20px; 
} 
#left { 
width:120px; 
background-color:green; 
position:absolute; 
} 
#middle { 
background-color:yellow; 
} 
#right { 
width:120px; 
background-color:green; 
position:absolute; 
top:0; 
right:0; 
} 
#foot { 
background-color:pink; 
} 
#main { 
position:relative; 
} 
</style> 
</head> 
<body> 
<p id="nav" class="page_center">上边</p> 
<p id="main" class="page_center"> 
<p id="left">左边</p> 
<p id="middle"> 中间部分</p> 
<p id="right">右边</p> 
</p> 
<p id="foot" class="page_center">底边</p> 
</body> 
</html>

範例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>Untitled Document</title> 
</head> 
<style type="text/css"> 
#left{ 
float:left; width:240px; height:500px; background:#0C9; 
} 
#right{ 
float:right;width:240px;height:500px; background:#933; 
} 
#center{ 
height:500px;background:#06C; 
} 
</style> 
<body> 
<p id="left" >左边</p> 
<p id="right" >右边</p> 
<p id="center" style="">中间</p> 
</body> 
</html>
<span style="font-size: 14px; font-family: Arial, Helvetica, sans-serif;"><strong></strong></span>

以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP中文網!

相關推薦:

關於CSS如何實作多行多列佈局的方法

以上是css頁面中左中右分欄佈局的實現的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn