Right to left Text HTML input

前端 未结 8 2260
名媛妹妹
名媛妹妹 2020-11-27 18:37

For my website, i need to provide arabic support. Part of it is to provide input textboxes where when user types in, the new characters have to be appended to the left and t

相关标签:
8条回答
  • 2020-11-27 19:15

    Here's what I can think of:

    • Use direction:RTL for the RIGHT alignment
    • Write a JavaScript handler attached to the event: "onkeyup", which performs the shifting of the entered character to the LEFT (doing some text processing).
    0 讨论(0)
  • 2020-11-27 19:23

    A feature specific to Angular Material, in addition to direction: rtl, is :

    .mat-form-field {
       text-align: start!important;
     }
    

    This will work for both RLT & LTR

    0 讨论(0)
  • 2020-11-27 19:27
    function rtl(element)
    {   
        if(element.setSelectionRange){
            element.setSelectionRange(0,0);
        }
    }
    
    
    
    
    <input type="text" name="textbox" style="direction:RTL;" onkeyup="rtl(this);"/>
    

    This code will do.

    0 讨论(0)
  • 2020-11-27 19:29

    You can use the dir="rtl" on the input. It is supported.

    <input dir="rtl" id="foo"/>
    
    0 讨论(0)
  • 2020-11-27 19:31

    Use on the input in css.

    input {
      unicode-bidi:bidi-override;
      direction: RTL;
    }
    
    0 讨论(0)
  • 2020-11-27 19:35

    It works for Chrome browser.
    Use a div element and make it editable.

        <div contenteditable="true">
        </div>
    
    0 讨论(0)
提交回复
热议问题