Ckeditor inline editor stays on screen when scrolling a “scrollable” div

谁说胖子不能爱 提交于 2019-12-13 18:30:36

问题


I have a "scrollable" div. Inside this div i have some text and another div with contenteditable=true.

The HTML source looks like this

<div id='scrollable' style="overflow:scroll;height:500px;width:90%;position:absolute">
some text
   <div id='editable' style="color:red" contenteditable=true>editable div</div>
some text
</div>

An inline ckeditor editor for the "editable" div should appear on page load. This is done by focusing the div.

 $( document ).ready(function() {
  $("#editable").focus();
});

The problem is that when i scroll the "scrollable" div the inline editor stays on screen. I want it to stay "out of screen" when i scroll. I mean, i want it to behave like a regular element inside a scrollable div.

I prepared a jsfiddle but for testing i recommend to view the result page separately. Tested in FF and Chrome


回答1:


You can do something like

$( document ).ready(function() {
  // Handler for .ready() called.
  $("#editable").focus();
     setInterval(function(){$("#cke_editable").css("top",($("#editable").offset().top - $("#cke_editable").height())+"px")})
});

See it work here



来源:https://stackoverflow.com/questions/30304210/ckeditor-inline-editor-stays-on-screen-when-scrolling-a-scrollable-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!