我有一个包含浮动图像,标题和说明的固定大小的div。我的问题是,当添加大量文本时,div不会停留在其父项的边界内。我想要的是文本在达到div底部时被省略号截断。我无法控制名称和desc div的内容长度,所以我无法对它们施加高度。这看起来很琐碎,但我无法弄清楚我要去哪里错了。 JSFiddle文本溢出:高度有限的div内灵活高度div的省略号
为了清楚起见,我的意思是,我想我的结果是这个样子:
{{name}}
{{desc.}} Lorem ipsum dolor
sit amet, consectetur adipisi
cing elit, sed do eiusmod tem
por incididunt ut labore et...
编辑:原来,这个问题是很多更复杂的比我的预期。这个问题与div边界没有任何关系,而是多行省略号结局并不是一件微不足道的事情。
HTML
<div id="data" class="clearfix">
<img id="icon" src="{{imgurl}}">
<div id="text">
<div id="name">{{name}}</div>
<div id="desc">{{desc}}</div>
</div>
</div>
CSS
#data {
background-color:red;
width:300px;
position: absolute;
margin: 23px 44px;
height: 100px;
padding: 10px 10px;
color: #fff;
text-overflow: ellipsis;
}
#icon {
background-color: grey;
width: 80px;
height: 80px;
float: left;
margin-right: 10px;
}
#text {
float: right;
width: 200px;
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
#name {
font-size: 18px;
font-weight: bold;
line-height: 1.5em;
}
#desc {
font-size: 13px;
line-height: 1.1em;
text-overflow: ellipsis;
}
你需要什么 ? –