2014-03-24 60 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有保證金和填補應該整理出來