问题
I am working on a multilingual layout. What worries me is:
How to handle text-input the right way?
I've build a JSFiddle to explain my problem.
- If I just add
dir="rtl"
, the words appear from right to left, but not each character - If I add the CSS style for right-to-left, the included numbers are also turned around
How can i combine numbers and text, so a hebrew input is showing correctly?
回答1:
You can try this solution from here
Example http://jsfiddle.net/0w5rydrL/1/
The html
<div class="text_direction" dir="rtl">
<input type="text" onkeyup="rtl(this);" />
</div>
The javascript function
function rtl(element){
if(element.setSelectionRange){
element.setSelectionRange(0,0);
}
}
来源:https://stackoverflow.com/questions/26361649/how-to-handle-right-to-left-text-input-fields-the-right-way