有没有人知道如何使用内联块的以下css技巧?
.text {
display: block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
我在同一行上有几个文本标签(h2& h3),即使我将display:block更改为inline-block,它仍然会弄乱布局。
有没有人做过类似的事情?
编辑:我只想连接h2(第一个元素),而不是h3标签内容。
答案 0 :(得分:1)
试试这个
p{
display: inline-block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

<p class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</p>
&#13;
答案 1 :(得分:0)
尝试将line-height
用于text
display:inline-block
课程
.text{
display: inline-block;
/* adjust line height for class text*/
line-height: 25px;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&#13;
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h3>
&#13;
答案 2 :(得分:0)
.text {
display: inline-block;
line-height:20px;
width: 200px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&#13;
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h3>
&#13;