<div id="wrap"> <div id="column1">這里是第一列</div> <div id="column2">這里是第二列</div> <div class="clear"></div>/*這是違背web標準意圖的,只是想說明在它下面的元素需要清除浮動*/</div>
#wrap{ width:100%; height:auto;}#column1{ float:left; width:40%;}#column2{ float:right; width:60%;}.clear{ clear:both;} <div id="wrap"> <div id="column1">這里是第一列</div> <div id="column2">這里是第二列</div></div>
#wrap{ position:relative;/*相對定位*/width:770px;}#column1{ position:absolute; top:0; left:0; width:300px;}#column2{position:absolute; top:0; right:0; width:470px;}body { margin: 0px; padding: 0px; text-align: center; }#content { margin-left:auto; margin-right:auto; width: 400px; }body { margin: 0px; padding: 0px; text-align: center;}#content-top { margin-left:auto; margin-right:auto; width: 400px; }#content-end {margin-left:auto; margin-right:auto; width: 400px; }body { margin: 0px; padding: 0px; text-align: center; }#content-top { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }#content-mid { margin-left:auto; margin-right:auto; width: 400px; }#content-end { margin-left:auto; margin-right:auto; width: 400px; }#bodycenter { width: 700px;margin-right: auto; margin-left: auto;overflow: auto; }#bodycenter #dv1 {float: left;width: 280px;}#bodycenter #dv2 {float: right;width: 420px;}#header{ width: 700px; margin-right: auto;margin-left: auto; overflow: auto;}#bodycenter { width: 700px; margin-right: auto; margin-left: auto; overflow: auto; }#bodycenter #dv1 { float: left; width: 280px;}#bodycenter #dv2 { float: right;width: 420px;}#header{ width: 700px;margin-right: auto; margin-left: auto; }#bodycenter {width: 700px; margin-right: auto; margin-left: auto; }#bodycenter #dv1 { float: left;width: 280px;}#bodycenter #dv2 { float: right; width: 420px;}#footer{ width: 700px; margin-right: auto; margin-left: auto; overflow: auto; clear:both; }#left { position: absolute; top: 0px; left: 0px; width: 120px; }#middle {margin: 0px 190px 0px 190px; }#right {position: absolute;top: 0px; right: 0px; width: 120px;}<div id="wrap"> <div id="column"> <div id="column1">這里是第一列</div> <div id="column2">這里是第二列</div> <div class="clear"></div>/*用法web標準不建議,但是記住下面元素需要清除浮動*/ </div> <div id="column3">這里是第三列</div> <div class="clear"></div>/*用法web標準不建議,但是記住下面元素需要清除浮動*/</div>
#wrap{ width:100%; height:auto;}#column{ float:left; width:60%;}#column1{ float:left; width:30%;}#column2{ float:right; width:30%;}#column3{ float:right; width:40%;}.clear{ clear:both;} <div id="center" class="column"> <h1>This is the main content.</h1> </div> <div id="left" class="column"> <h2>This is the left sidebar.</h2> </div> <div id="right" class="column"> <h2>This is the right sidebar.</h2> </div>
body { margin: 0; padding-left: 200px; /* LC fullwidth */ padding-right: 190px; /* RC fullwidth + CC padding */ min-width: 200px; /* LC fullwidth + CC padding */ }.column { position: relative; float: left; }#center { width: 100%; }#left { width: 200px; /* LC width */ right: 200px; /* LC fullwidth */ margin-left: -100%; }#right { width: 190px; /* RC width */ margin-right: -100%; } /*** IE Fix ***/* html #left { left: 190px; /* RC fullwidth */ }<div id="header">這里是頂行</div><div id="warp"> <div id="column"> <div id="column1">這里是第一列</div> <div id="column2">這里是第二列</div> <div class="clear"></div> </div> <div id="column3">這里是第三列</div> <div class="clear"></div></div>
#header{width:100%; height:auto;}#wrap{ width:100%; height:auto;}#column{ float:left; width:60%;}#column1{ float:left; width:30%;}#column2{ float:right; width:30%;}#column3{ float:right; width:40%;}.clear{ clear:both;} <div id="header">這里是頂行</div><div id="wrap"> <div id="column"> <div id="column1">這里是第一列</div> <div id="column2">這里是第二列</div> <div class="clear"></div> </div> <div id="column3">這里是第三列</div> <div class="clear"></div></div><div id="footer">這里是底部一行</div>
#header{width:100%; height:auto;}#wrap{ width:100%; height:auto;}#column{ float:left; width:60%;}#column1{ float:left; width:30%;}#column2{ float:right; width:30%;}#column3{ float:right; width:40%;}.clear{ clear:both;} #footer{width:100%; height:auto;}div.content { width:400px; //這個是錯誤的width,所有瀏覽器都讀到了voice-family: """}"""; //IE5.X/win忽略了"""}"""后的內容voice-family:inherit;width:300px; //包括IE6/win在內的部分瀏覽器讀到這句,新的數值(300px)覆蓋掉了舊的} html>body .content { //html>body是CSS2的寫法width:300px; //支持CSS2該寫法的瀏覽器(非IE5)有幸讀到了這一句} div.content { width:300px !important; //這個是正確的width,大部分支持!important標記的瀏覽器使用這里的數值width(空格)/**/:400px; //IE6/win不解析這句,所以IE6/win仍然認為width的值是300px;//而IE5.X/win讀到這句,新的數值(400px)覆蓋掉了舊的,因為!important標記對他們不起作用} html>body .content { //html>body是CSS2的寫法width:300px; //支持CSS2該寫法的瀏覽器有幸讀到了這一句} <div id="wrap"><div id="column1">這是第一列</div><div id="column1">這是第二列</div><div class="clear"></div></div>
#wrap{ width:776px; background:url(bg.gif) repeat-y 300px;}#column1{ float:left; width:300px;}#column2{ float:right; width:476px;}.clear{ clear:both;}新聞熱點
疑難解答