将浮动ext面板放在左下角

时间:2019-01-22 23:20:25

标签: javascript css extjs

ExtJS 的新功能。我试图将浮动 Ext.panel.Panel 放置在浏览器窗口的左下角,但无济于事。请查看下面的代码段,让我知道我在做什么错。预先感谢。

// JavaScript
Ext.define('examplePanel.view.ExamplePanel', {
    extend: 'Ext.panel.Panel',
    xtype: 'exPanel',
    width: 138,
    floating: true,
    cls: 'example-panel',
    closeAction: 'hide',
    collapsible: true,
    defaultAlign: 'bl-bl',
    fixed: true,
    border: true,
    layout: {
        type: 'vbox',
        align: 'stretch'
    },
    header: {
        title: 'Example',
        titleAlign: 'center',
        cls: 'panel-header'
    },
    items: [
        // item 1
        // item 2
    ]
});

// CSS
.example-panel {
  position: fixed;
  bottom: 0;
  left: 0;
}

1 个答案:

答案 0 :(得分:1)

这是一个可能的解决方案:

FIDDLE

Ext.application({
    name : 'Fiddle',

    launch : function() {
        var panel = Ext.create({
            xtype: 'panel',
            title: 'Left Bottom',
            frame: true,
            renderTo: Ext.getBody(),
            height: 200,
            width: 400,
            collapsible: true
        });

        //Get the doc measurements
        var body = document.body;
        var html = document.documentElement;

        var height = Math.max( body.scrollHeight, body.offsetHeight,
                       html.clientHeight, html.scrollHeight, html.offsetHeight );

        var width =  Math.max( body.scrollWidth, body.offsetWidth,
                       html.clientWidth, html.scrollWidth, html.offsetWidth );

        //Position the pnel
        panel.setPosition((width - panel.getWidth()),(height - panel.getHeight()));

    }
});
相关问题