1、字体居中
1 a{ 2 /*去掉a标签的下划线*/ 3 text-decoration: none; 4 /*水平居中*/ 5 text-align: center; 6 /*行高=元素的height 垂直居中*/ 7 line-height: 50px; 8 /*相对定位*/ 9 position: relative; 10 left: 70px; 11 }
2、水平居中
1 { 2 width:200px; 3 margin:0 auto; 4 }
3、绝对定位水平垂直居中
1 { 2 position: absolute; 3 width: 200px; 4 height: 100px; 5 margin: auto; 6 top: 0; 7 left: 0; 8 bottom: 0; 9 }