简体   繁体   English

将跨度放在可编辑div的最后一行旁边

[英]place span next to the last line of an editable div

I try to do something similar to the location label in the Facebook message box which is always next to the last text line while we are typing. 我尝试执行类似于Facebook消息框中的位置标签的操作,该位置始终在我们键入时位于最后一个文本行旁边。

在此处输入图片说明

I tried with a two inline spans , but the location label appears next to the right border of the text span as you can see. 我尝试使用两个内联spans ,但是如您所见,位置标签显示在文本span的右边框旁边。

在此处输入图片说明

Without any Javascript to dynamically place the location label, is it possible to do something similar to Facebook? 没有任何Javascript动态地放置位置标签,是否有可能做类似于Facebook的事情?

Take a look at this Fiddle 看看这个小提琴

HTML: HTML:

<div>
    <span class="textarea" class="status" contenteditable="true">foo
foobarfoobar
bar</span>
    <span contenteditable="false"> — at Montréal</span>
</div>

CSS: CSS:

div{
    width: 190px; 
    border: 1px solid #dedee0;
    padding: 10px;
}

.textarea{
    white-space: pre-wrap;
    display: inline-block
}

.location{
  display: inline-block  
}

And if you use inline only?: FIDDLE 如果仅使用内联?: FIDDLE

.textarea{
    white-space: pre-wrap;
    display: inline;
}

.location{
  display: inline;
}

Inside .textarea , change to display: inline; .textarea内部,更改为display: inline;

Also, I don't know if this was intentional, but you never applied the "location" class to the second span. 另外,我不知道这是否是故意的,但您从未将“ location”类应用于第二个跨度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM