[英]On down arrow key cursor going inside a div containing image
I am modifying bootstrap based HTML editor. 我正在修改基于bootstrap的HTML编辑器。 I have done image uploading part.In image uploading, I am creating an image inside a div. 我已经完成了图像上传部分。在图像上传中,我在div中创建了一个图像。
<div style="border: 1px solid;padding: 10px; width: 300px;resize: both;overflow: auto;">
<img src="uploads/images/dark_knight.jpg">
</div>
I want image to be resizeable hence, 我希望图像可以调整大小,因此,
element.style {
border: 1px solid;
padding: 10px;
width: 300px;
resize: both;
overflow: auto;
}
But the issue is when I am hitting a down key cursor is going inside a div containing an image (instead of below a div). 但问题是当我按下一个向下键的光标进入一个包含图像的div(而不是一个div)。
so what changes should I do in order to bring cursor below a div on pressing key down? 那么我应该做些什么改变才能按下按键将光标移到div下面?
Simply adding 只需添加
contenteditable="false"
to the div containing the image seems to solve the problem. 包含图像的div似乎解决了问题。
#editor { overflow: scroll; max-height: 250px; height: 250px; background-color: white; border-collapse: separate; border: 1px solid rgb(204, 204, 204); padding: 4px; box-sizing: content-box; -webkit-box-shadow: rgba(0, 0, 0, 0.0745098) 0px 1px 1px 0px inset; box-shadow: rgba(0, 0, 0, 0.0745098) 0px 1px 1px 0px inset; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border-top-left-radius: 3px; overflow: scroll; outline: none; } div { display: block; }
<div id="editor" contenteditable="true">First line <div> //after clicking down arrow key cursor going inside an image div <div style="border: 1px solid;padding: 10px; width: 300px;resize: both;overflow: auto;" contenteditable="false"> <img src="abcd.jpg"> </div> </div> <div> <br> </div> <div>Last line</div> </div>
Demo: http://jsfiddle.net/u37cxxbh/2/ 演示: http : //jsfiddle.net/u37cxxbh/2/
Make div contenteditable="false"
and add textarea
element next to image. 使div contenteditable="false"
并在图像旁边添加textarea
元素。 As in example above. 如上例所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.