How to align texts inside of an input?

后端 未结 7 1189
情深已故
情深已故 2020-12-02 08:58

For all default inputs, the text you fill starts on the left. How do you make it start on the right?

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 09:26

    If you want to get it aligned to the right after the text looses focus you can try to use the direction modifier. This will show the right part of the text after loosing focus. e.g. useful if you want to show the file name in a large path.

    input.rightAligned {
      direction:ltr;
      overflow:hidden;
    }
    input.rightAligned:not(:focus) {
      direction:rtl;
      text-align: left;
      unicode-bidi: plaintext;
      text-overflow: ellipsis;
    }

    The not selector is currently well supported : Browser support

提交回复
热议问题