<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;}