在tabs层中增加属性fit=“true”,动态添加的ifrme如果设置高度为100%,tabs选项卡上面如果有内容会出现底部显示不全的显示所谓的不能自动适应高度。需要调整高度小于100%目的是为了减去tabs上面部分高度。
下面为详细代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="jquery,ui,easy,easyui,web">
<meta name="description" content="easyui help you build your web page easily!">
<title>jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="easyuinew/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyuinew/themes/icon.css">
<script type="text/javascript" src="easyuinew/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="easyuinew/jquery.easyui.min.js"></script>
<script>
function addTab(title, url){
if ($('#tt').tabs('exists', title)){
$('#tt').tabs('select', title);
} else {
var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:90%;"></iframe>';
$('#tt').tabs('add',{
title:title,
content:content,
closable:true
});
}
}
$(function() {
addTab('首页', 'http://www.csdn.net');
});
</script>
</head>
<body>
<div style="margin-bottom:0px">
<a href="#" class="easyui-linkbutton" οnclick="addTab('google','http://www.google.com')">google</a>
<a href="#" class="easyui-linkbutton" οnclick="addTab('jquery','http://jquery.com/')">jquery</a>
<a href="#" class="easyui-linkbutton" οnclick="addTab('easyui','http://jeasyui.com/')">easyui</a>
</div>
<div id="tt" class="easyui-tabs" style="width:400px;height:250px;" fit="true">
<div title="Home">
</div>
</div>
</body>
</html>