我不能以绝对div为中心?

时间:2015-06-25 07:16:47

标签: html css

This is issue

在我的服务器HERE

上查看此问题
name = abinhav 
Location =Bangalore 
Id =613636064725610496 
Details = infoodnetwork: Q2 is up. You can still join the Megakitchens in India contest and grab some exciting vouchers. RT if you are enjoying… 

name = Mathi 
Location =Chennai 
Id =613636066474508289 
Details = i am the drifter Of course they can, but the BBC needs a daily negative story on India.

请帮助。

1 个答案:

答案 0 :(得分:0)

使用transform: translate

.login-div {
  background: #fff none repeat scroll 0 0;
  height: 500px;      
  width: 500px;          
  z-index: 99999;      
  position: absolute; top: 50%; left: 50%;
  -webkit-transform: translate(-50%,-50%);
  -ms-transform: translate(-50%,-50%);
  transform: translate(-50%,-50%);
}

body{
    background: #ccc;
}

.login-div {
    background: #fff none repeat scroll 0 0;
    height: 500px;
    width: 500px;
    z-index: 99999;
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}
<div class="login-div"></div>

.login-div {
      background: #fff none repeat scroll 0 0;
      height: 500px;      
      width: 500px;          
      z-index: 99999;      
      position: absolute; top: 50%; left: 50%;
      margin-top: -250px;
      margin-left: -250px;
    }

body{
    background: #ccc;
}

.login-div {
    background: #fff none repeat scroll 0 0;
    height: 500px;
    width: 500px;
    z-index: 99999;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -250px;
    margin-left: -250px;
}
<div class="login-div"></div>