如何使能DIV垂直和水平居中
2012-01-26 17:33
246 查看
<style type="text/css">
.center-middle1 {
position:absolute;
background-color: #e2e2e2;
width: 100%;
height: 300px;
top:50%;
margin-top: -150px; }
.center-middle2 {
position:absolute;
background-color: #e2e2e2;
width: 300px;
height: 200px;
left:50%;
top:50%;
margin-left: -150px;
margin-top: -100px; }
</style>
用例:
<div class="enter-middle2">
如何使能DIV垂直和水平居中
</div>
.center-middle1 {
position:absolute;
background-color: #e2e2e2;
width: 100%;
height: 300px;
top:50%;
margin-top: -150px; }
.center-middle2 {
position:absolute;
background-color: #e2e2e2;
width: 300px;
height: 200px;
left:50%;
top:50%;
margin-left: -150px;
margin-top: -100px; }
</style>
用例:
<div class="enter-middle2">
如何使能DIV垂直和水平居中
</div>
相关文章推荐
- 如何让div水平居中以及垂直居中,在宽高不定的情况下
- DIV+CSS架构下 如何使DIV中文字水平和垂直居中
- 如何让图片相对于上层DIV始终保持水平、垂直都居中
- 如何将一个div水平垂直居中?4种方法做推荐
- 如何让DIV水平和垂直居中
- 如何使div垂直水平居中的css代码
- 如何让一个div水平和垂直居中对齐
- css中如何使div居中(垂直水平居中)
- 如何让图片在垂直方向与 div的底部对齐 水平居中
- 父元素为一个div,宽度高度不固定,子元素是一个块状元素,宽高已知,如何实现子元素在父元素内水平、垂直居中?
- 【转】如何让DIV水平和垂直居中
- 如何实现嵌套的内部div垂直水平居中
- 如何使一个div在另一个div中绝对居中(水平与垂直方向)
- 未知大小的img或div如何水平垂直居中显示?
- 如何让DIV水平和垂直居中
- 如何让DIV里面的DIV水平垂直居中
- 如何使img或者div在div中水平垂直居中显示
- html中div如何水平和垂直居中的几种css方法代码
- 如何让div水平垂直居中
- 如何让DIV水平和垂直居中