javascript - 居中对齐 - EXTJS 4

标签 javascript ajax extjs extjs4 alignment

var loginForm = new Ext.form.FormPanel({
           frame: true,
           border: true,
           height: 155,
           width: 350,
           layout: {
            type: 'hbox',
            },
            items: [{
                     xtype: 'image',
                     src : 'images/system-users.png',
                     width: 100,
                   },{
                        xtype: 'container',

                        defaults: {
                            labelWidth: 80,

                        },
                        layout: {
                            type: 'vbox',
                            //align: 'stretch',
                            padding:'0 0 20 0'
                        },  
                       items: [{
                                 xtype: 'textfield',
                                 width: 250,
                                 id: 'username',
                                 fieldLabel: 'Username'
                               },{
                                 xtype: 'textfield',
                                 width: 250,
                                 id: 'password',
                                 fieldLabel: 'Password ',
                                 inputType: 'password',
                                 submitValue: false
                               },{
                                 xtype: 'hidden',
                                 id: 'challenge',
                                 value: "<?php echo $challenge; ?>",
                                 submitValue: false
                               },btnLogin],
           }
           ]//contain items    
         });

enter image description here

问题

这是一个现场演示 http://jsfiddle.net/anthor/WM9DD/88/
1)如何将登录按钮居中对齐?
2)图像和所有文本框对齐窗口框的中心和中间。

最佳答案

试试这个:

var loginForm = new Ext.form.FormPanel({
 frame: true,
 border: true,
 layout: {
     type: 'hbox',
     align: 'stretch'
 },

 items: [{
     xtype: 'image',
     src: 'images/system-users.png',
     width: 100,
 }, {
     xtype: 'container',

     defaults: {
         labelWidth: 80,

     },
     layout: {
         type: 'vbox',
         align: 'stretch',
         padding: '0 0 20 0'
     },
     flex: 1,
     items: [{
         xtype: 'textfield',
         id: 'username',
         fieldLabel: 'Username'
     }, {
         xtype: 'textfield',
         id: 'password',
         fieldLabel: 'Password ',
         inputType: 'password',
         submitValue: false
     }, {
         xtype: 'hidden',
         id: 'challenge',
         value: "<?php echo $challenge; ?>",
         submitValue: false
     }, {
         xtype: 'container',
         layout: {
             type: 'hbox',
             pack: 'end'
         },
         items: [btnLogin]
     }],
 }] //contain items    
 });

在 hbox 布局中,您可以向项目添加 align: 'stretch' 选项和 flex: 1 选项来拉伸(stretch)它们。我还将按钮放入另一个容器中以将其粘在右侧。

关于javascript - 居中对齐 - EXTJS 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15014754/

相关文章:

c# - Visual Studio 打包 : Another version of this product is already installed

python - App Engine 应用程序中的 CORS(python)

javascript - 无法在选择框更改时将数据发送到 php

javascript - jquery (ajax) click 使 php 脚本运行多次

javascript - Ext Grid 定位在视口(viewport)或其他东西中

javascript - 您如何检测移动网络浏览器上由滑动手势引起的滚动已经结束?

Javascript:document.getElementbyID(..) 为 null 或不是对象

c# - 在浏览器控件中以编程方式填写 PDF 表单字段

css - 按下按钮时更改背景行颜色

titanium - 我对用于移动Web应用程序开发的工具/框架感到困惑