从右到左文本 HTML 输入 [英] Right to left Text HTML input

查看:29
本文介绍了从右到左文本 HTML 输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的网站,我需要提供阿拉伯语支持.其中一部分是提供输入文本框,当用户输入时,新字符必须附加到左侧,文本必须右对齐.

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 the text has to be right aligned.

设置css属性为

text-align:right

不起作用,因为我无法将光标移到左侧并在那里添加字母.所以我删除了该属性并添加了

didn't work, as i could not get the cursor to come to the left and add letters there. So I removed that property and added

direction:RTL

在这里,光标移到左边,文本右对齐.但是新添加的字符没有附加到左侧.相反,它们仅附加到右端.

Here, the cursor came to the left and text was right aligned. but the newly added characters were not getting appended to the left. Instead they were getting appended to the right end only.

我该如何解决这个问题?请帮忙..

How do I fix this? please help..

例如,查看 google 阿拉伯语页面搜索框.我需要确切的行为,虽然不需要那些花哨的键盘图标等,http://www.google.com/webhp?hl=ar

For example, see the google arabic page search box. I need the exact behavior, although not with those fancy keyboard icon etc., http://www.google.com/webhp?hl=ar

推荐答案

以下是我能想到的:

  • 使用 direction:RTL 进行右对齐
  • 编写一个附加到事件的 JavaScript 处理程序:onkeyup",它执行将输入的字符向左移动(进行一些文本处理).

这篇关于从右到左文本 HTML 输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆