【问题标题】:How to show two paragraph in a single with dots using css?如何使用css在一个带有点的单个段落中显示两个段落?
【发布时间】:2018-10-27 15:37:39
【问题描述】:

代码:

<div id="over_flow">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>

    <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

css:

overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;

我有一个 div,其中我有两个具有动态内容的段落,它可能尽可能长。现在,我在这里做什么,我想在两三行之后用dots(...) 显示我的数据,但现在看起来不太好。那么,我该怎么做呢?请帮帮我。

谢谢

【问题讨论】:

标签: html css


【解决方案1】:

对于单行,您可以尝试以下代码

#over_flow p {
      white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
<div id="over_flow">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>

    <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

对于 2 或 3 行有以下代码

改变行数改变-webkit-line-clamp: 2;属性

#over_flow p {  
    line-height: 30px;
    overflow:hidden; 
    font-size: 20px;    

    /*The problematic part is below*/   
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
<div id="over_flow">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>

    <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-13
    • 1970-01-01
    • 1970-01-01
    • 2010-11-10
    • 1970-01-01
    • 2018-08-11
    • 2020-06-21
    相关资源
    最近更新 更多