[英]Create content-editable div following span with text inside
Here is a image of what kind of effect I'm trying to have: 这是我要达到的效果的图像:
ICON LINE - 1 Some text Inside a div element
and the next line should start
here
ICON LINE - 2 Some text Inside a div element
and the next line should start
here
ICON LINE - 3 Some text Inside a div element
and the next line should start
here
And here is the code I tried: 这是我尝试的代码:
<div>
<div>
<span style="padding-left: 40px;">ICON</span>
<div contenteditable="true" style="display:inline-block; padding-left: 20px; width:200; position: absolute;">
<font> LINE 1 -- Some text Inside a div element and the next line should start here kjdaskjdaskldjaskldjaskldjaskldjaskljdaskljdaslkjdkl</font>
</div>
</div>
<div>
<span style="padding-left: 40px;">ICON</span>
<div contenteditable="true" style="display:inline-block; padding-left: 20px; width:200; position: absolute;">
<font>LINE 2 -- Some text Inside a div element and the next line should start here kjdaskjdaskldjaskldjaskldjaskldjaskljdaskljdaslkjdkl</font>
</div>
</div>
</div>
and here is a demo: http://jsfiddle.net/supersuraccoon/djv83qpd/1/ 这是一个演示: http : //jsfiddle.net/supersuraccoon/djv83qpd/1/
It's almost there but as you can see in the link above all the text are overlapping. 它几乎在那儿,但是正如您在链接上方所看到的,所有文本都是重叠的。
Any suggestion will be appreciated, thanks :) 任何建议将不胜感激,谢谢:)
Forget absolute
positioning. 忘记
absolute
定位。 Add px
to your width
s and add vertical-align:top;
将
px
添加到您的width
s中,并添加vertical-align:top;
to your divs so 对你的div来说
<div contenteditable="true" style="display:inline-block; padding-left: 20px; width:200px; vertical-align:top;">
Try This :: [i have added only <br> <br>
] 试试这个:: [我仅添加了
<br> <br>
]
<div>
<div>
<span style="padding-left: 40px;">ICON</span>
<div contenteditable="true" style="display:inline-block; padding-left: 20px; width:200; position: absolute;">
<font> LINE 1 -- Some text Inside a div element and the next line should start here kjdaskjdaskldjaskldjaskldjaskldjaskljdaskljdaslkjdkl</font>
</div>
</div>
<br><br>
<div>
<span style="padding-left: 40px;">ICON</span>
<div contenteditable="true" style="display:inline-block; padding-left: 20px; width:200; position: absolute;">
<font>LINE 2 -- Some text Inside a div element and the next line should start here kjdaskjdaskldjaskldjaskldjaskldjaskljdaskljdaslkjdkl</font>
</div>
</div>
</div>
fiddle :: http://jsfiddle.net/djv83qpd/5/ 小提琴:: http://jsfiddle.net/djv83qpd/5/
Try this 尝试这个
<div class="container clearfix">
<div class="blocks clearfix">
<div class="image">
Image1
</div>
<div class="lines">
<div>Line one text</div>
<div>First block text First block text First block text</div>
</div>
</div>
<div class="blocks clearfix">
<div class="image">
Image2
</div>
<div class="lines">
<div>Line two text</div>
<div>Second block text Second block text Second block text</div>
</div>
</div>
<div class="blocks clearfix">
<div class="image">
Image3
</div>
<div class="lines">
<div>Line three text</div>
<div>Third block text Third block text Third block text</div>
</div>
</div>
</div>
css is CSS是
.clearfix:after {
content: " ";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
.container{
margin: 0 auto;
width: 70%;
}
.blocks .image, .blocks .lines{
float: left;
}
.blocks .image {
border: 1px solid grey;
margin: 5px;
height: 100px;
width: 100px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.