How to Change CSS direction property of the input field automaticly if the user can use an language rtl or ltr

前端 未结 5 904
失恋的感觉
失恋的感觉 2021-02-06 08:49

Example: if I use arabic language the text field direction will be rtl and if I want to write a new text and I switch to the English language the direction inside the text field

5条回答
  •  梦如初夏
    2021-02-06 09:11

    aaaaand the css needed is "direction" with the values of "ltr" or "rtl"

    css:

    textarea.rtl
    {
      direction:rtl;
    }
    
    textarea.ltr
    {
      direction:ltr;
    }
    

    or

    document.getElementById("myTextArea").style.direction = "rtl"
    

    supported by all major browsers.

提交回复
热议问题