I need an overflow to truncate from the left, with ellipses

前端 未结 3 1302
遇见更好的自我
遇见更好的自我 2020-12-10 10:59

Briefly, I have a field where the rightmost digits are most significant. (Naturally, this field comes from our affiliates\' systems, based on their primary keys, so the left

相关标签:
3条回答
  • 2020-12-10 11:27

    I am unable to test it now, but I am pretty certain that adding

    direction: rtl;
    

    will do the expected result.

    0 讨论(0)
  • 2020-12-10 11:38

    Try to use this trick:

    HTML

    <p class="ellipsis">ert3452654546</p>
    

    CSS

    .ellipsis {
        overflow: hidden;
        width: 60px;
        direction: rtl; 
        margin-left: 15px;
        white-space: nowrap;
    }
    
    .ellipsis:after {
        position: absolute;
        left: 0px;
        content: "...";
    }​
    

    FIDDLE

    0 讨论(0)
  • 2020-12-10 11:44

    You can use a css class to have this kind of behavior like:

    .responsive-text {
      display: inline-block;
      vertical-align: middle;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      direction: rtl;
      width: 100%;
    }
    

    You only have to define the size of the container of this text and every time that the text inside doesn't fill in only one line, it's going to truncate the text and adds ... at the beginning.

    0 讨论(0)
提交回复
热议问题