【发布时间】:2019-01-11 06:15:36
【问题描述】:
请检查DEMO 并在 contenteditable 元素上写一个长文本。
每当 contenteditable 内容超出其父边界时,父 div 内容就会向左推。
<div class="voucher-template">
<div class="voucher-background"></div>
<div class="content-editable" contenteditable="true">
sample text
</div>
</div>
.voucher-template {
width: 500px;
height: 250px;
position: relative;
border: 2px solid #808080;
overflow: hidden;
}
.voucher-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: teal;
}
.content-editable {
position: absolute;
top: 90px;
left: 350px;
font-size: 30px;
color: #fff;
border: 2px dashed gray;
}
编辑:它实际上是一个凭证编辑器。您可以拖动和移动 contenteditable 元素。我只是没有包含插件(jqueryUI draggable 和 TinyMCE),因为它纯粹是 html css 问题而不是 js 插件。 editor screenshot
编辑:我更新了演示,启用了可拖动的 jquery ui 以避免混淆。 contenteditable 是可拖动和可编辑的。
【问题讨论】:
-
好吧……我们仍然不知道你真正想要做什么……向右展开……换行并向右对齐……?
-
抱歉,请尝试演示。用很长的文本编辑 contenteditable 元素。问题是为什么父内容向左移动。我已经更新了问题,请看截图。
-
好的,已经解决了。
标签: jquery html css jquery-ui tinymce