2013-01-03 64 views
1

我創建了一個應用程序,可在啓動時啓動視口。這覆蓋整個屏幕。所以我提供了一個寬度和高度。下一個要求是應用程序在屏幕中居中對齊。居中對齊視口

我用的代碼是:

//<debug> 
Ext.Loader.setConfig({disableCaching:false}); 
Ext.Loader.setPath({ 
'Ext': 'sdk/src' 
}); 
//</debug> 

Ext.application({ 
name: 'SEPA', 
controllers: ["MainController"], 
requires: [ 
    'Ext.MessageBox' 
], 

controllers:['MainController'], 

icon: { 
    57: 'resources/icons/Icon.png', 
    72: 'resources/icons/Icon~ipad.png', 
    114: 'resources/icons/[email protected]', 
    144: 'resources/icons/[email protected]' 
}, 

phoneStartupScreen: 'resources/loading/Homescreen.jpg', 
tabletStartupScreen: 'resources/loading/Homescreen~ipad.jpg', 
fullscreen: false, 
//centered:true, 
// margin: 100, 

launch: function() { 
    Ext.Viewport.setWidth(320); 
    Ext.Viewport.setHeight(480); 

    //Ext.Viewport.setCentered(false); 
    // Ext.Viewport.setRight(2); 

    // Destroy the #appLoadingIndicator element 

}, 

onUpdated: function() { 
    Ext.Msg.confirm(
     "Application Update", 
     "This application has just successfully been updated to the latest version. Reload now?", 
     function() { 
      window.location.reload(); 
     } 
    ); 
} 
}); 

正如你所看到的,應用程序被放置在瀏覽器的最左邊的角落。我怎樣才能把它放在屏幕的中心?

enter image description here

任何幫助表示讚賞。 在此先感謝。

回答

1

添加到您的cssscss文件:

body { 
    position:absolute; 
    left:50%; 
    top:50%; 
    margin-left:-160px; 
    margin-top:-240px; 
} 

希望它能幫助:)

+0

大。有效。非常感謝。 – Khush

+0

@Hhush很高興幫助:) – Eli