I have a div with contenteditable set to true to act as a text input. Now usually, it expands as some text reaches the end of the div, but if I resize the div, this stops happening. The browser no more does this. I tried to set the height after resizing it to auto, but it didn't help either.

Please help me on that one. Thanks.

有帮助吗?

解决方案

If you've set the height absolute the browser will handle it absolute. So apply the following css rules to your div:

#yourdiv {
    height: auto;
    min-height: 150px;
}

其他提示

Here you have an example: http://html5demos.com/contenteditable look at it's source code with chrome or firebug.

It all goes around the width, height, and overflow. You should also be carefull with the word-wrap property. Check it out! :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top