简体   繁体   English

如何调整div元素的大小,使其小于其内容?

[英]How to resize div element less than its content?

I have a table and there is a TreeView in a cell. 我有一张桌子,一个单元格中有一个TreeView。 Here is my code: 这是我的代码:

   <style>
        #leftPanel
        {
            width:60px;
            height:'100%';
            border:1px solid red;
            background:yellow;
        }  
    <style>

        <table>
         <tr>
          <td> 
           <div id="leftPanel">
             <asp:PlaceHolder runat="server" ID="TreeView" />
             <%-- Here is a TreeView --%>
           </div>
          </td>
         </tr>
          <%-- other code --%>
        <table>

 $(function () {
         $('#leftPanel').resizable(
         {
             handles: 'e, w'
         });
     });

I can't reduce the size of my div less then the size of my TreeView. 我无法将div的大小减小到小于TreeView的大小。 What code need I write to allow leftPanel to be less than the size of TreeView ? 我需要编写什么代码以使leftPanel小于TreeView的大小? It is necessary if TreeView node's text too long. 如果TreeView节点的文本太长,则很有必要。

You can set the overflow property for the div in CSS. 您可以在CSS中为div设置overflow属性。

Set it to overflow: auto; 将其设置为overflow: auto;

DEMO 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM