2014-02-10 75 views
1

所以我在backbone.marionette中構建了自己的自定義模態框,但是我遇到了這個問題,每當我模式,我的頁面向下移動大約一半英寸。很煩人。任何人有想法如何解釋這個或解決它?當顯示固定'模態'div時頁面移動

這裏是我的#modal.overlay CSS:

#modal { 
    position: fixed; 
    top: 0; 
    left:0; 
    right:0; 
    margin-left:auto; 
    margin-right:auto; 
    z-index: 1002; 
    width: 70%; 
} 

.overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.85); 
    z-index: 1001; 
} 

回答

0

找到了解決辦法 - 如果我模態的top屬性設置爲0,並給它的一切,那麼就沒有惱人的偏移margin-top。這是我登陸的最終的CSS:

#modal { 
    position: fixed; 
    top: 0; 
    left:0; 
    right:0; 
    margin-top: 2em; 
    margin-left:auto; 
    margin-right:auto; 
    z-index: 1002; 
    width: 70%; 
} 
相關問題