w3pop.com :: ÍøÂçѧԺ :: WEBÉè¼Æ×ÛºÏ :: DIV+CSSÍøÒ³²¼¾Ö³£Óõķ½·¨Óë¼¼ÇÉ
DIV+CSSÍøÒ³²¼¾Ö³£Óõķ½·¨Óë¼¼ÇÉ
::
CSS²¼¾Ö³£Óõķ½·¨
float:none|left|right
ȡֵ£º
none:¤ˆÄ¬ÈÏÖµ¡£¶ÔÏ󲻯®¸¡
left:¤ˆÎı¾Á÷Ïò¶ÔÏóµÄÓÒ±ß
right:¤ˆÎı¾Á÷Ïò¶ÔÏóµÄ×ó±ß
ËüÊÇÔõÑù¹¤×÷µÄ£¬¿´¸öÒ»ÐÐÁ½ÁеÄÀý×Ó
xhtml´úÂë:
<div id="wrap">
<div id="column1">ÕâÀïÊǵÚÒ»ÁÐ</div>
<div id="column2">ÕâÀïÊǵڶþÁÐ</div>
/*ÕâÊÇÎ¥±³web±ê×¼ÒâͼµÄ£¬Ö»ÊÇÏë˵Ã÷ÔÚËüÏÂÃæµÄÔªËØÐèÒªÇå³ý¸¡¶¯*/
</div>
CSS´úÂë:
#wrap{width:100;height:auto;}
#column1{float:left;width:40;}
#column2{float:right;width:60;}
.clear{clear:both;}
position:static|absolute|fixed|relative
ȡֵ£º
static:¤ˆÄ¬ÈÏÖµ¡£ÎÞÌØÊⶨ룬¶ÔÏó×ñÑHTML¶¨Î»¹æÔò
absolute:¤ˆ½«¶ÔÏó´ÓÎĵµÁ÷ÖÐÍϳö£¬Ê¹ÓÃleft£¬right£¬top£¬bottomµÈÊôÐÔÏà¶ÔÓÚÆä×î½Ó½üµÄÒ»¸ö×îÓж¨Î»ÉèÖõĸ¸¶ÔÏó½øÐоø¶Ô¶¨Î»¡£Èç¹û²»´æÔÚÕâÑùµÄ¸¸¶ÔÏó£¬ÔòÒÀ¾Ýbody¶ÔÏó¡£¶øÆä²ãµþͨ¹ýz-indexÊôÐÔ¶¨Òå
fixed:¤ˆÎ´Ö§³Ö¡£¶ÔÏó¶¨Î»×ñ´Ó¾ø¶Ô(absolute)·½Ê½¡£µ«ÊÇÒª×ñÊØÒ»Ð©¹æ·¶
relative:¤ˆ¶ÔÏ󲻿ɲãµþ£¬µ«½«ÒÀ¾Ýleft£¬right£¬top£¬bottomµÈÊôÐÔÔÚÕý³£ÎĵµÁ÷ÖÐÆ«ÒÆÎ»ÖÃ
ËüÀ´ÊµÏÖÒ»ÐÐÁ½ÁеÄÀý×Ó
xhtml´úÂë:
<div id="wrap">
<div id="column1">ÕâÀïÊǵÚÒ»ÁÐ</div>
<div id="column2">ÕâÀïÊǵڶþÁÐ</div>
</div>
CSS´úÂë:
[www.52css.com]
#wrap{position:relative;/*Ïà¶Ô¶¨Î»*/width:770px;}
#column1{position:absolute;top:0;left:0;width:300px;}
#column2{position:absolute;top:0;right:0;width:470px;}
ËûÃǵÄÇø±ðÔÚÄÄ£¿
ÏÔÈ»£¬floatÊÇÏà¶Ô¶¨Î»µÄ£¬»áËæ×Åä¯ÀÀÆ÷µÄ´óСºÍ·Ö±æÂʵı仯¶ø¸Ä±ä£¬¶øposition¾Í²»ÐÐÁË£¬ËùÒÔÒ»°ãÇé¿öÏ»¹ÊÇfloat²¼¾Ö£¡
CSS³£Óò¼¾ÖʵÀý
µ¥ÐÐÒ»ÁÐ
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:0px190px0px190px;}
#right{position:absolute;top:0px;right:0px;width:120px;}
float¶¨Î»Ò»
xhtml´úÂë:
<div id="wrap">
<div id="column">
<div id="column1">ÕâÀïÊǵÚÒ»ÁÐ</div>
<div id="column2">ÕâÀïÊǵڶþÁÐ</div>
/*Ó÷¨web±ê×¼²»½¨Ò飬µ«ÊǼÇסÏÂÃæÔªËØÐèÒªÇå³ý¸¡¶¯*/
</div>
<divid="column3">ÕâÀïÊǵÚÈýÁÐ</div>
/*Ó÷¨web±ê×¼²»½¨Ò飬µ«ÊǼÇסÏÂÃæÔªËØÐèÒªÇå³ý¸¡¶¯*/
</div>
CSS´úÂë:
#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;}
float¶¨Î»¶þ
xhtml´úÂ룺
<div id="center"class="column">
<h1>Thisisthemaincontent.</h1>
</div>
<div id="left"class="column">
<h2>Thisistheleftsidebar.</h2>
</div>
<div id="right"class="column">
<h2>Thisistherightsidebar.</h2>
</div>
CSS´úÂ룺
body{
margin:0;
padding-left:200px;/*LCfullwidth*/
padding-right:190px;/*RCfullwidth CCpadding*/
min-width:200px;/*LCfullwidth CCpadding*/
}
.column{
position:relative;
float:left;
}
#center{
width:100;
}
#left{
width:200px;/*LCwidth*/
right:200px;/*LCfullwidth*/
margin-left:-100;
}
#right{
width:190px;/*RCwidth*/
margin-right:-100;
}
ÆÀÂÛ (0)
All