如何在div

时间:2018-01-30 04:01:20

标签: javascript jquery html css jquery-easyui

在我的项目中,我使用easyui-layout。

有时,我应该使用ajax从其他页面加载其他内容。这些新内容将被放置在cenDiv的中心区域。

ajax代码是:

$.ajax({
        .....
        success:function(data)
        {
            $("#cenDiv").html(data);
            .......
        }
      });    

现在,我遇到了一个问题。当溢出cenDiv的内容太多时,没有滚动。因此,只有部分内容以cenDiv显示。

这是我的HTML代码:

<body style="height:100%" class="easyui-layout" fit="true">
 <div id="firDiv" class="easyui-layout"  style="width:100%;height:88%;position:absolute;top:95px">
   <div  style="background:lightgrey;width:10%;height:100%;padding:10px" data-options="region:'west',split:true,title='Function'"></div>

   <div id="cenDiv" class="easyui-layout"  style="position:static;height:100%;width:100%" data-options="region:'center',title:''">
    <div class="easyui-layout" style="position:static;height:3000px" data-options="region:'north',title:'',split:true">
       north-John-Stack
    </div>
    <div class="easyui-layout" style="position:static;height:100px" data-options="region:'south',title:''">
       south-Tyrion-Lanniste
    </div>
   </div>
 </div>
</body>

我设置了fit =&#34; true&#34;在身体,firDiv和cenDiv,但它的工作失败。因为身体的高度,firDiv和cenDiv都会改变。

我尝试了overflow:auto,但它再次失败了。

当内容数据太多时,只有cenDiv显示滚动,而其他div位置不会更改。

谁能帮帮我?

2 个答案:

答案 0 :(得分:0)

您需要在cenDiv上使用max-height和overflow-y:

let n = "lighthouse"
var nScore = 0
for i in n.indices {
    let curChar = n[i]
    let curVal = dict[curChar, default: 0]
    nScore = 1 + (nScore + curVal - 1) % 9
}
nScore //7

如果没有最大高度,滚动就不会出现。

无论如何,你使用了太多的高度:100%,内部的div和#34; firDiv&#34;有它。 你可以这样改变它们:

max-height: 100px;
overflow-y: auto;

答案 1 :(得分:0)

删除位置:静态,并添加

overflow-y:auto

工作正常,如:

<div id="cenDiv" class="easyui-layout"  style="height:100%;width:100%;overflow-y:auto" data-options="region:'center',title:''">