jquery - 具有自动消耗的内容可编辑的 div

标签 jquery html css

我正在使用 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/

相关文章:

javascript - Angular 函数结果未显示在 DOM 中

javascript - Uncaught ReferenceError : toggleTest is not defined

html - 如何将所有社交媒体按钮放在一条线上

javascript - 单击后悬停不会重置

javascript - 对列表而不是行进行排序

jquery - 如何解析 Controller 中的 json 值以在 jquery/ajax 中查看

javascript - Angular JS动态设置tabindex属性

javascript - jquery - .mouseover 功能并不总是适用于移动设备

jquery - 具有动态数据库变量调用的 CSS 定位 - 移位

html - CSS:无法垂直移动我的按钮