Asp.net/Html DIV高度(根据内容高度) [英] Asp.net/Html DIV Height According to Content Height

查看:67
本文介绍了Asp.net/Html DIV高度(根据内容高度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET页面中有两个网格,

我将DIV用于滚动条,为此我使用了以下查询

I have two grid in an ASP.NET page,

I used DIV for scroll bar,for that i used the following query

<div style="height:300px;overflow:auto;display: inline-block;">
                       <asp:GridView ID="grdBillableMonth" runat="server"

                           CssClass="tablestyle" Height="27px">
                           <AlternatingRowStyle CssClass="altrowstyle" />
                           <HeaderStyle CssClass="headerstyle" />
                           <RowStyle CssClass="rowstyle" />
                       </asp:GridView>
 </div>



没有滚动条刚好到达网格的尽头并根据DIV的内容调整大小

那就是DIV宽度随着Content会自动改变.


现在我需要的是高度,
我希望DIV高度根据内容的高度而变化,不仅如此,
我想设置一个高度限制.
即,如果我的网格的高度为500px ..如果在绑定期间,假设它只有200px的高度,则DIV应该减小到200px的高度,但是在绑定时,网格的高度超过500px,那么它会显示滚动条而不是增加身高


任何人都可以帮助



No the Scroll bar is coming just to end of the grid and resizing according to content of the DIV

That is DIV width is changing automatically with Content.


Now my need is I want the same in the case of Height,
i want DIV height changing according to height of the content,not only that,
i want to set a limit for height.
ie, if height of my grid is 500px..if during binding,say it have only 200px height,the DIV should reduce to 200px height,but when binding,the gird gets more than 500px height,then it shows a scroll bar instead of increasing height


Can anyone help

推荐答案

使用最大高度样式.
这是供您测试的快速html块

Use the max-height style.
Here''s a quick html block for you to test

<div style="max-height:100px; overflow:scroll; background-color:#aaf;">
<div contenteditable="true">Type more lines here and check</div>
</div>


这篇关于Asp.net/Html DIV高度(根据内容高度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆