css考核点整理(六)-水平居中定位的几种方式
- 定宽
父容器position:relative;子容器 position:absolute;left:50%; margin-left: 宽度/2
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
- 不定宽
display:inline-block; vertical-align:middle;
参考文章
http://blog.csdn.net/freshlover/article/details/11579669
厚积薄发