我正在使用 contenteditable=true 的 div。它可以像这样自动扩展:http://html5demos.com/contenteditable
但我需要的是扩展应该是反向的,如果我按回车键,div 应该扩展到上侧而不是下侧。
最佳答案
我不确定你能做到这一点,因为 html 文档从左到右、从上到下扩展,你可以做的是在创建新行时向下滚动……这会产生这样的错觉div 向上扩展。
尝试在函数中添加:
window.scrollBy(0,fontHeight);
或者使用 jQuery:
$('div[contenteditable=true]').animate({
scrollTop: '+=xx' //xx= fontHeight
}, 1000);
关于jquery - 具有自动消耗的内容可编辑的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16141533/