css 浮動和定位的兩種三欄布局

來源:互聯網
上載者:User
Code:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
  3.   
  4. <head>  
  5.     <meta http-equiv="content-type" content="text/html; charset=gb2312" />  
  6.     <meta name="author" content="WWW.DOWNG.COM" />  
  7.   
  8.     <title>css 浮動和定位的兩種三欄布局</title>  
  9.     <style type="text/css">  
  10.         *{margin:0;padding:0;}  
  11.         body{text-align:center;}  
  12.         .wrap{margin:auto;position:relative;text-align:left;width:800px;}  
  13.           
  14.         /*浮動*/  
  15.         #left{float:left;background-color: silver;width:150px;}  
  16.         #middle{float:left;width:500px;background-color:pink;}  
  17.         #right{  
  18.             float:left;  
  19.             background-color:gray;width:150px;}  
  20.         .footer{clear:both;background-color:black;color:white;}  
  21.               
  22.          /*相對定位*/  
  23.         /*    #left{position:absolute;left:0px; top:50px;width:150px;background-color: silver}  
  24.             #middle{position:absolute;left: 150px;top:50px;width:500px;background-color:pink;}  
  25.             #right{position:absolute;left: 650px;top:50px;width:150px;background-color: silver}  
  26.             .footer{display:none;}  
  27.         }*/  
  28.   
  29.     </style>  
  30.     <script type="text/javascript">  
  31.       
  32.     </script>  
  33. </head>  
  34.   
  35. <body>  
  36.   
  37. <div class="wrap">  
  38.     <div id="left">left  
  39.   </div>  
  40.     <dir id="middle">middle      
  41.     </dir>  
  42.     <dir id="right">right  
  43.     </dir>  
  44.     <dir class="footer">  
  45.         footer  
  46.     </dir>  
  47. </div>  
  48. </body>  
  49. </html>  

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.