2014-03-24 62 views
1

我试图在屏幕上居中横向和纵向的div,但不知何故它略微偏离中心。这是为什么?我认为这是因为内容的,但我不知道:dDiv偏离中心

我用

height:90%; 

margin-top:5% 

使其居中。

下面是完整的代码: http://jsfiddle.net/7mNue/1/

回答

1

DIV应用margin: auto并设置一个全尺寸(width & height)。

+0

不,仍然离中心 – virhonestum

0

试试这个

.popup{ 
    width:100%; // remove this and add below style 
    max-width:100%; 
} 

.popup img{ 
    max-width:100%; 
} 
+0

不,对我不起作用 – virhonestum

0

box-sizing: border-box有保证金和填补应该整理出来