为了账号安全,请及时绑定邮箱和手机立即绑定

ExtJs用Absolute布局和Accordion布局

标签:
Html/CSS

ExtJs其实在某种程度上可以代替div+css来进行页面布局(不过经测试,在最新的Firefox3下,部分功能好象有点问题),今天我们来学习二种最基本的布局

1.Absolute 布局:这种最容易理解,直接用x,y值来绝对定位组件

2.Accordion布局:Accordion意为"手风琴",即最终效果可以象手风琴那样拉来拉去,说白了,就是类似QQ面板的功能。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css" />
     <script type="text/javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="../adapter/ext/ext-base.js"></script>
    <script type="text/javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="../ext-all-debug.js"></script> 
    <script type="text/javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="../Extjs_Intellisense.js"></script>
    <title>Layout_Border示例</title>
    <style type="text/css">
        #panel2 .x-panel-body {
            background:#ffe;
            color:#15428B;
        }
        #panel2 .x-panel-header-text {
            color:#f00;
        }
    </style>
</head>
<body>
<script type="text/javascript">
    Ext.onReady(function() {
        
        //layout:absolute(绝对定位布局)
        var win = new Ext.Window({
            title: "Absolute Layout",
            height: 400,
            width: 400,
            plain: true,
            x: 10,
            y:10,
            layout:'absolute',
            items: [
                new Ext.Panel({
                    title:"panel 1",
                    x:50,
                    y: 50,
                    width: 100,
                    height:100,
                    html:"Positioned at x:50,y:50",
                    frame:true
                }),
                new Ext.Panel({
                    title: "panel 2",
                    x: 125,
                    y: 125,
                    width: 100,
                    height: 100,
                    html: "Positioned at x:125,y:125",
                    frame: true
                })
            ]
        })
        win.show();
        //layout:Accordion(类似QQ面板的布局)
        var win2 = new Ext.Window({
            title: "Accordion Layout",
            height: 400,
            width: 200,
            x: 420,
            y:10,
            plain: true,
            layout: 'accordion',
            items: [
                new Ext.Panel({
                    title: "panel 1",
                    id:"panel1",                  
                    html: "panel one",
                    frame: true
                }),
                new Ext.Panel({
                    title: "panel 2",
                    id:"panel2",
                    html: "panel two",
                    frame: true
                })
            ]
        })
        win2.show();
    });
</script>
</body>
</html>


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消