Extjs---HBox的使用

html中的代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<script src="ext4/ext-all.js" type="text/javascript"></script>
		<link href="ext4/resources/css/ext-all.css" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript" src="js/hbox.js"></script>
	</head>
	<body>
		<div id="d1"></div><br>
	</body>
</html>

hbox.js中的代码:

Ext.onReady(function() {
	var hbox1 = Ext.create('Ext.Panel', {
		title : 'HBox 顶对齐,且组件在容器的左边',
		frame : true,
		width : 600,
		height : 100,
		//renderTo:Ext.getBody(),
		items : [ {
			anchor : '100%',
			layout : {
				//设置布局为hbox
				type : 'hbox',
				padding : '10',
				//指定组件在容器中的位置;
				//start(默认):组件在容器左边,center:组件在容器中间,end:组件在容器的右边 
				pack : 'start',
				//指定组件在容器内的对齐方式
				//top(默认):排列于容器顶端。
				//middle:垂直居中排列于容器中。
				//stretch:垂直排列且拉伸义填补容器高度
				//stretchmax:垂直拉伸,并且组件以最高高度的组件为准。
				align : 'top'
			},
			defaults : {
				margins : '0 0 5 5'
			},
			items : [ {
				xtype : 'button',
				text : 'Button 1'
			}, {
				xtype : 'button',
				text : 'Button 2'
			}, {
				xtype : 'button',
				text : 'Button 3'
			}, {
				xtype : 'button',
				text : 'Button 4'
			} ]
		} ]
	})
	//渲染到html页面中的d1层
	hbox1.render('d1');
})
效果图



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值