对div定位的理解
positon有4个属性:static relative absolute fixed.
默认的时候是static即静止定位,是按照元素在(x)html出现的顺序依次分配位置,static是不受top right left bottom影响的.
当父层a的position设为relative(相对定位) 子层b的position设为absolute(绝对定位)时,b的偏移是相对于父层a来定位,例如top:10px的偏移量就使b的顶部和a的顶部有10px的距离.但是如果a没有设置relative 而b设为absolute,b的定位就是相对于浏览器进行,此时top:10px会使b出现在离浏览器上方10px的地方.
-----------------------div居底部-----------------
--------------------------------------------------------
一、水平居中
.hor_center {
margin: 0 auto;
}
二、水平垂直居中
.content {
width: 360px;
height: 240px;
}
.ver_hor_center {
position: absolute;
top: 50%;
left: 50%;
width:360px;
height:240px;
margin-left: -180px; /*要居中的div的宽度的一半*/
margin-top: -120px; /*要居中的div的高度的一半*/
}
三、div置于底部(footer)
.bottom_footer {
position: fixed; /*or前面的是absolute就可以用*/
bottom: 0px;
}
http://www.wibibi.com/info.php?tid=138
http://blog.sina.com.cn/s/blog_92d6237201016jhs.html
http://blog.csdn.net/sykent/article/details/7791284