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/Icon@2x.png',
    144: 'resources/icons/Icon~ipad@2x.png'
},

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();
        }
    );
}
 });

如您所见,该应用程序位于浏览器的最左角。我怎样才能让它在屏幕的中心?

在此处输入图像描述

任何帮助表示赞赏。提前致谢。

4

1 回答 1

1

将此添加到您的cssorscss文件中:

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

希望能帮助到你 :)

于 2013-01-03T04:57:16.733 回答