网页布局入门教程 如何用CSS进行网页布局

2020-05-11 18:09:09易采站长站整理

<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>三列布局</title>  
<style>  
body{ margin:0; padding:0; font-size:30px; font-weight:bold}   
div{ text-align:center; line-height:50px}   
.left{ width:240px; height:600px; background:#ccc; position:absolute; left:0; top:0}   
.main{ height:600px; margin:0 240px; background:#9CF}   
.right{ height:600px; width:240px; position:absolute; top:0; right:0; background:#FCC;}   
</style>  
</head>  
  
<body>  
  
    <div class="left">left</div>  
    <div class="main">main</div>  
    <div class="right">right</div>  
</body>  
</html>  
  

DEMO:http://Lovejulyer.github.io/Source_Code/Blog_demo/Codes2/sanliezuoyouguding.html

五、混合布局及结构与表现原则

混合布局01

XML/HTML Code复制内容到剪贴板

<!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>混合布局01</title>  
<style>  
    body{ margin:0; padding:0; font-size:30px; font-weight:bold}   
    div{ text-align:center; line-height:50px}   
    .head{ height:100px;background:#9CF}   
    .left{ width:20%; height:600px; background:#ccc; float:left}   
    .right{ width:80%; height:600px;background:#FCC; float:right}/*宽度设置为百分数,以实现自适应*/   
</style>  
</head>  
  
<body>  
    <div class="head">head</div>  
    <div class="left">left</div>  
    <div class="right">right</div>