简体   繁体   English

在内部设计中可编辑的div高度变化

[英]contenteditable div height change working inside design

Hopefully this is somewhat simple to figure out. 希望这很容易弄清楚。 I have a list of items of an unknown height and a content editable div underneath it. 我有一个未知高度的项目列表,其下方有一个内容可编辑的div。 I need to figure out how to resize the list when the content editable div gets bigger with content. 我需要弄清楚当内容可编辑div的内容变大时如何调整列表大小。 Is there a css trick that I missed somewhere? 我在某处错过了CSS技巧吗? Do I need to listen for an event? 我需要听事件吗? What's the best solution here? 最好的解决方案是什么?

Here is a fiddle to show what I'm talking about. 这是用来显示我在说什么的小提琴

here's html structure in the fiddle just cause it makes me post code with a fiddle. 小提琴中的html结构只是因为它使我用小提琴来编写代码。

<div class="containerDiv" ng-controller="MyController">
    <ul>
        <li ng-repeat="item in items">
            <p>{{item.message}}</p>
        </li>
    </ul>
    <div id="inputDiv" contenteditable></div>
    <button ng-click="addItem()">Add</button>
</div>

For example look at the facebook chat window. 例如,查看Facebook聊天窗口。 How does it resize when you have multiple lines of text before you send the message? 在发送消息之前有多行文本时,如何调整大小? Is there a simpler way of doing it? 有更简单的方法吗?

First, you need to encapsulate your list in a div and let that div be dynamically handled by CSS. 首先,您需要将列表封装在div中,然后让该div由CSS动态处理。

You would then need to modify your height property and make the same 'auto'. 然后,您需要修改您的height属性并进行相同的“自动”设置。

Next, provide a min-height if you require. 接下来,根据需要提供最小高度。

containerDiv {
    border:1px solid blue;
    height:auto;
    width:150px;
    min-height:100px;
}
.containerDiv ul {
    height:auto;
    overflow-y:auto;
}

Updated JS Fiddle: http://jsfiddle.net/q78jN/1/ 更新了JS Fiddle: http : //jsfiddle.net/q78jN/1/

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

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