1:Ext.layout.FitLayout

   它是最简单的布局方式,如果要使用这种布局,只需要设置容器的layout属性为fit就可以了,即使容器中指定了多个面板,只会渲染第一个面板,它通常

用于菜单、表单等的嵌套布局。

代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>FitLayout</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="ext3.2/resources/css/ext-all.css"></link>
<script type="text/javascript" src="ext3.2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext3.2/ext-all.js"></script>
<script type="text/javascript" src="ext3.2/src/local/ext-lang-zh_CN.js"></script>

<script type="text/javascript">
Ext.onReady(function() {
var panel = new Ext.Panel({
renderTo: 'fitLayout',
title: '自适应布局',
width: 400,
height: 200,
layout: 'fit',
frame: true,
defaults: {
bodyStyle: 'background-color: #FFFFFF; padding: 3px'
},
items: [{
title: 'panel1',
html: '<p>这是panel1内层面板的内容</p>',
border: false
}, {
title: 'panel2',
html: '<p>这是panel2内层面板的内容</p>',
border: false
}]
});
});
</script>
</head>
<body>
<div id="fitLayout"></div>
</body>
</html>

2:程序效果图

 

    如果将代码中的layout:'fit'去掉,运行结果如图: