css实现文本过长时自动添加省略号

2. Html

<div >
    <div class="long-text-test1">
        好长
    </div>
    <div class="long-text-test1">
        好长好长好长好长好长好长好长好长好长
    </div>
    <div class="long-text-test2">
        好长
    </div>
    <div class="long-text-test2">
        好长好长好长好长好长好长好长好长好长
    </div>
</div>

  

3. Less

.process-long-text-001(@width:100px) {
  width: @width;
  overflow: hidden;
  -ms-text-overflow: ellipsis;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.long-text-test1 {
  .process-long-text-001();
}

.long-text-test2 {
  .process-long-text-001(200px);
}

  

 

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-06-08
  • 2021-07-15
猜你喜欢
  • 2022-12-23
  • 2021-05-24
  • 2021-09-28
  • 2021-08-12
  • 2022-12-23
  • 2021-12-12
  • 2022-01-22
相关资源
相似解决方案