css 超长标题中间省略

css 超长标题中间省略_第1张图片

重点是 :before 中加两个css属性

  • direction: rtl;
  • float: right;
<span
 title="CSS 测试标题,这是一个稍微有点长的标题,超出一行以后才会有title提示,标题是 实现优惠券的技巧 - 2021-03-26" 
 class="branch_name_front
 ">
 CSS 测试标题,这是一个稍微有点长的标题,超出一行以后才会有title提示,标题是 实现优惠券的技巧 - 2021-03-26
 span>
.branch_name_front {
    display: block;
    text-align: justify;
    overflow: hidden;
    height: 20px;
    white-space: normal;
}
.branch_name_front::before{
    content: attr(title);
    width: 60%;
    float: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;
}

你可能感兴趣的:(css,css,前端,html)