要使用VBox布局方式,首先的熟悉下一下几个主要属性:
一、align:字符类型,指示组件在容器内的对齐方式。有如下几种属性。
1、left(默认):排列于容器左侧。
2、center :控件在容器水平居中。
3、stretch:控件横向拉伸至容器大小
4、stretchmax:控件横向拉伸,宽度为最宽控件的宽。
二、flex:数字类型,指示组件在容器中水平呈现方式,通俗的讲,就是指示组件在容器中的相对宽度。
三、pack : 字符类型,指示组件在容器的位置,有如下几种属性。
1、start(默认):组件在容器上边
2、center:组件在容器中间
3、end:组件在容器的下边
HTML代码:
- <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<htmlxmlns="http://www.w3.org/1999/xhtml">
- <head>
-
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
- <title>VBox---MHZG.NET</title>
-
<linkrel="stylesheet"type="text/css"href="../../resources/css/ext-all.css"/>
-
<scripttype="text/javascript"src="../../bootstrap.js"></script>
-
<scripttype="text/javascript"src="../../locale/ext-lang-zh_CN.js"></script>
-
<scripttype="text/javascript"src="vbox.js"></script>
-
<styletype="text/css">
- html,body{
- font:normal12pxverdana;
- margin:0;
- padding:0;
- border:0none;
- }
- </style>
- </head>
-
- <body>
- </body>
- </html>
vbox.js:
- Ext.onReady(function(){
-
varcurrentName;
-
varreplace=function(config,name){
-
varbtns=Ext.getCmp('btns');
-
if(name&&name!=currentName){
- currentName=name;
- btns.remove(0);
- btns.add(Ext.apply(config));
- }
- };
-
-
varviewport=Ext.create('Ext.Viewport',{
-
layout:'border',
-
- items:[{
-
id:'btns',
-
region:'west',
-
baseCls:'x-plain',
-
split:true,
- width:150,
- minWidth:100,
- maxWidth:250,
-
layout:'fit',
-
margins:'5055',
- items:{
-
baseCls:'x-plain',
-
html:'<pstyle="padding:10px;color:#556677;font-size:11px;">点击右边的按钮查看效果</p>'
- }
- },{
-
region:'center',
-
margins:'5550',
-
layout:'anchor',
- items:[{
-
anchor:'100%',
-
baseCls:'x-plain',
- layout:{
-
type:'hbox',
- padding:10
- },
- defaults:{
-
margins:'0500',
-
pressed:false,
-
toggleGroup:'btns',
-
allowDepress:false
- },
- items:[{
-
xtype:'button',
-
-
text:'Spaced/Align:left',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'left'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'tbspacer',
- flex:1
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4',
-
margins:'0'
- }]
-
},'spaced');
- }
- },{
-
xtype:'button',
-
text:'Multi-Spaced/Align:left',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'left'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'tbspacer',
- flex:1
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'tbspacer',
- flex:1
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'tbspacer',
- flex:1
- },{
-
xtype:'button',
-
text:'Button4',
-
margins:'0'
- }]
-
},'multispaced-alignleft');
- }
- },{
-
xtype:'button',
-
text:'Align:left',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'left'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4'
- }]
-
},'alignleft');
- }
- },{
-
xtype:'button',
-
text:'Align:center',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'center'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4'
- }]
-
},'aligncenter');
- }
- },{
-
xtype:'button',
-
text:'Align:stretch',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'stretch'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4'
- }]
-
},'alignstretch');
- }
- },{
-
xtype:'button',
-
text:'Align:stretchmax',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'stretchmax'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Jamie'
- },{
-
xtype:'button',
-
text:'Aaron'
- },{
-
xtype:'button',
-
text:'Tommy'
- },{
-
xtype:'button',
-
text:'Ed'
- }]
-
},'alignstretchmax');
- }
- }]
- },{
-
anchor:'100%',
-
baseCls:'x-plain',
- layout:{
-
type:'hbox',
-
padding:'01010'
- },
- defaults:{
-
margins:'0500',
-
pressed:false,
-
toggleGroup:'btns',
-
allowDepress:false
- },
- items:[{
-
xtype:'button',
-
text:'Flex:Even/Align:center',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'center'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1',
- flex:1
- },{
-
xtype:'button',
-
text:'Button2',
- flex:1
- },{
-
xtype:'button',
-
text:'Button3',
- flex:1
- },{
-
xtype:'button',
-
text:'Button4',
- flex:1,
-
margins:'0'
- }]
-
},'alignflexeven');
- }
- },{
-
xtype:'button',
-
text:'Flex:Ratio/Align:center',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'center'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1',
- flex:1
- },{
-
xtype:'button',
-
text:'Button2',
- flex:1
- },{
-
xtype:'button',
-
text:'Button3',
- flex:1
- },{
-
xtype:'button',
-
text:'Button4',
- flex:3,
-
margins:'0'
- }]
-
},'alignflexratio');
- }
- },{
-
xtype:'button',
-
text:'Flex+Stretch',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
align:'stretch'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1',
- flex:1
- },{
-
xtype:'button',
-
text:'Button2',
- flex:1
- },{
-
xtype:'button',
-
text:'Button3',
- flex:1
- },{
-
xtype:'button',
-
text:'Button4',
- flex:3,
-
margins:'0'
- }]
-
},'alignflex+stretch');
- }
- },{
-
xtype:'button',
-
text:'Pack:start/Align:center',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
pack:'start',
-
align:'center'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4'
- }]
-
},'alignpackstart+aligncenter');
- }
- },{
-
xtype:'button',
-
text:'Pack:center/Align:center',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
pack:'center',
-
align:'center'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4',
-
margins:'0'
- }]
-
},'alignpackcenter+aligncenter');
- }
- },{
-
xtype:'button',
-
text:'Pack:end/Align:center',
-
handler:function(){
- replace({
- layout:{
-
type:'vbox',
-
padding:'5',
-
pack:'end',
-
align:'center'
- },
-
defaults:{margins:'0050'},
- items:[{
-
xtype:'button',
-
text:'Button1'
- },{
-
xtype:'button',
-
text:'Button2'
- },{
-
xtype:'button',
-
text:'Button3'
- },{
-
xtype:'button',
-
text:'Button4',
-
margins:'0'
- }]
-
},'alignpackend+aligncenter');
- }
- }]
- }]
- }]
- });
- });
分享到:
相关推荐
ExtJS4学习笔记(五)---Grid分页 ExtJS4学习笔记(六)---多表头Grid ExtJS4学习笔记(七)---带搜索的Grid(SearchGrid) ExtJS4学习笔记(八)---Grid多选/全选 ExtJS4学习笔记(九)---ExtJS4 EditGrid(可编辑的Grid) ...
ExtJS4学习笔记(三)---VBox的使用 ExtJS4学习笔记(九)---ExtJS4 EditGrid(可编辑的Grid) ExtJS4学习笔记(二)---HBox的使用 ExtJS4学习笔记(五)---Grid分页 ExtJS4学习笔记(八)---Grid多选 全选 ExtJS4学习笔记(六)--...
extjs-theme-bootstrap-master.zip
目录 1. ExtJs 结构树 2 2. 对ExtJs的态度 3 3. Ext.form概述 4 4. Ext.TabPanel篇 5 5. Function扩展篇 7 6. Ext.data.Store篇 10 7. Ext.data.JsonReader篇一 12 ...28. extJs 2.0学习笔记(ext.js篇) 77
NULL 博文链接:https://lucky16.iteye.com/blog/1490278
extjs2----关于extjs 的使用,操作.比较初级,但是也比较使用。适合初步接触extjs的朋友
Extjs 5 学习笔记,在网上下载整理好的。
exjts4 学习笔记源码,源码包含windws,hbox,vbox和Grid的应用,其中grid介绍比较多。下载解压后,部署后就可以使用,所有代码均在demo文件夹下。更多extjs4教程,请关注http://www.mhzg.net
语言程序设计资料:ExtJs学习笔记-2积分.doc
ExtJs学习笔记,共30讲 1. ExtJs 结构树 2 2. 对ExtJs的态度 3 3. Ext.form概述 4 4. Ext.TabPanel篇 5 5. Function扩展篇 7 6. Ext.data.Store篇 10 7. Ext.data.JsonReader篇一 12 8. Ext.data.JsonReader篇二 15 ...
官方最新版本Extjs6.2版本sdk,创建新项目的时候需要用, 全面的核心框架,具有最新的Javascript标准支持 新的漂亮组件和主题,以创建漂亮的企业应用程序 现代工具链,用于构建优化,高性能,通用的应用程序 用于可视...
自己总结的extjs4学习笔记,自己总结的extjs4学习笔记,自己总结的extjs4学习笔记,
extjs_4.1.0_community_extjs4-mvc-complex-dashboard
一个extjs的OA项目 extjs-OA extjs-oaextjs-OA extjs-oa
NULL 博文链接:https://lucky16.iteye.com/blog/1522254
NULL 博文链接:https://chenxueyong.iteye.com/blog/336117
extjs4.0开发人员以及学习可以下载参考
ext基本的控件例子ext基本的控件例子ext基本的控件例子ext基本的控件例子