CSS定位机制:

1、标准文档流 normal flow

2、浮动 float

3、绝对定位 absolute positioning (position: absolute; 或者 position: fixed) 绝对定位会忽略float属性


居中大全 http://www.cnblogs.com/ranzige/p/4010742.html

内联元素居中

1、水平居中: text-align: center;

2、垂直居中: height: 20px; line-height: 20px; 问题:多行内联元素垂直居中,如多行文字

块级元素居中

1、块水平居中: width:80%; margin:0 auto; (如果不设置width,默认width为100%,看不出居中效果) 问题:多个块元素在水平居中

2、块垂直居中:给当前块元素的父元素加属性:display: table-cell;  vertical-align: middle; 

 posted on 2014-10-06 17:24  喵喵喵  阅读(135)  评论(0编辑  收藏  举报