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

cssこれをまたはscssファイルに追加します。

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

それが役に立てば幸い :)

于 2013-01-03T04:57:16.733 に答える