HTML——上中下布局,上中下布局
上中下布局是最基本的布局方式,本例假設使用者螢幕解析度為800*600像素。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>上中下布局</title><style type="text/css">body{background: #42413C ;margin: 0;/*消除body中的留白*/padding: 0;text-align: center;}.container{width: 778px;background: #FFF;margin: 0 auto;/*側邊的自動值與寬度結合使用,可以將布局置中對齊*/text-align: left;}.header{padding: 10px 0;background: #ADB96E;}.content{padding: 10px 0;}.footer{padding: 0px;background: #CCC49F;}</style></head><body><div class="container"><div class="header"><h1>網頁頭部</h1></div><div class="content"><h1>網頁本文</h1><h1>網頁本文</h1><h1>網頁本文</h1><h1>網頁本文</h1><h1>網頁本文</h1></div><div class="footer"><h1>腳註</h1></div></div></body></html>
HTML--div/Div上中下布局問題
不用設定高度,可以在三個div的樣式裡都添加float:left;clear:both;
<style>
div{
float:left;
clear:both;
border:1px solid #999;
width:40px;
word-break : break-all;
}
</style>
<div id="demo1">fdasgdsafd</div>
<div id="demo2">fdasgdsafdfdsafdsagdasfdsagdsafdsafdsagdsaf</div>
<div id="demo3">fdasgdsafd</div>
關鍵是div{}裡的前兩行,後面三行只是為了讓你看效果,你可以任意更換<div></div>中間的內容去嘗試
怎用div+css布局出上中下三個html檔案?具體代碼,謝大俠
<iframe src="top.html" width="100%" height="200">
您的瀏覽器不支援架構
</iframe>
<iframe src="middle.html" width="100%" height="200" >
您的瀏覽器不支援架構
</iframe>
<iframe src="down.html" width="100%" height="200">
您的瀏覽器不支援架構
</iframe>
基本就是這樣實現的,還有一些具體屬性可以百度一下