【问题标题】:Ellipsis not working correctly in Safari with line-clamp带线夹的 Safari 中的省略号无法正常工作
【发布时间】:2020-03-10 10:05:51
【问题描述】:

我正在使用 line-clamp 将博客中的标题限制为最多两行。它在 firefox 和 chrome 中运行良好,但在 safari 中,省略号不会出现在它应该出现的位置,而是出现在句子的中间。

我正在使用 bootrap 4,但也发生在使用 Foundation 6 制作的另一个项目上,似乎在将 flex 用于网格时发生。

<div class="row">
    <div class="col-6">
        <h1 class="title">
            <a href="#">Long title goes here</a>
        </h1>
    </div>
</div>

还有scss

$enh1-font-size: 50px;
$enh1-line-height: 60px;
$enh1-lines-to-show: 2;
.title {
  display: block;
  display: -webkit-box;
  max-height: $enh1-line-height*$enh1-lines-to-show;
  margin: 0 auto;
  font-size: $enh1-font-size;
  line-height: $enh1-line-height;
  -webkit-line-clamp: $enh1-lines-to-show;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

结果应该是这样的:

Lorem ipsum dolor sit amet, consectetur
肥胖精英。 Etiam luctus dapibus...

相反,我得到了这个:

Lorem ipsum dolor sit amet, consectetur
adipiscing el... Etiam luctus dapibus

【问题讨论】:

    标签: css safari


    【解决方案1】:

    在这种情况下,它是 &lt;a href="#"&gt;Long title goes here&lt;/a&gt;,而不是将线夹 css 分配给 h1 分配给 具有长文本的元素

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 2016-12-23
      相关资源
      最近更新 更多